Viewing file: Fivesim_api.php (10.74 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Fivesim_Api { function get_balance() { $api_key = get_instance()->config->item("fivesim_api_key"); return explode(":",file_get_contents("http://api1.5sim.biz/stubs/handler_api.php?api_key={$api_key}&action=getBalance"))[1]; } public function get_number($country, $service, $operator) { $api_key = get_instance()->config->item("fivesim_api_key"); //$op = array_keys($this->get_cheapest($country,$service))[0]; $res = file_get_contents("http://api1.5sim.biz/stubs/handler_api.php?api_key={$api_key}&action=getNumber&operator={$operator}&country={$country}&service={$service}"); $data = explode(":", $res); if(count($data) != 3) { $error_code = 400; if($res == "NO_NUMBER") $error_code = 103; return array( "id" => 0, "number" => null, "error_code" => $error_code ); } else { file_get_contents("http://api1.5sim.biz/stubs/handler_api.php?api_key={$api_key}&action=setStatus&id={$data[1]}&status=1"); return array( "id" => (int)$data[1], "number" => $data[2], "error_code" => 200 ); } } public function get_message($id) { $api_key = get_instance()->config->item("fivesim_api_key"); $res = file_get_contents("http://api1.5sim.biz/stubs/handler_api.php?api_key={$api_key}&action=getStatus&id={$id}"); $data = explode(":", $res); if(count($data) > 1) { array_shift($data); file_get_contents("http://api1.5sim.biz/stubs/handler_api.php?api_key={$api_key}&action=setStatus&id={$id}&status=6"); return array( "code" => join(':', $data) ); } else { return array( "code" => null ); } } public function get_service_stock($country, $service) { $json = json_decode(file_get_contents("https://5sim.biz/v1/guest/products/{$country}/any"), true); $json_service = $json[$service]; return $json_service["Qty"]; } public function get_countries() { $countries = array(); $json = json_decode(file_get_contents("https://5sim.biz/v1/guest/countries"), true); foreach(array_keys($json) as $country) { array_push($countries, array("id" => $country, "name" => $country)); } return $countries; } public function get_countries_new() { $countries = array(); $tr = array( "any" => "any", "afghanistan" => "Afganistan", "albania" => "Arnavutluk", "algeria" => "Cezayir", "angola" => "Angola", "antiguaandbarbuda" => "Antigua ve Barbuda", "argentina" => "Arjantin", "armenia" => "Ermenistan", "austria" => "Avusturya", "azerbaijan" => "Azerbaycan", "bahrain" => "Bahreyn", "bangladesh" => "Bangladeş", "barbados" => "Barbados", "belarus" => "Belarus", "benin" => "Benin", "bhutane" => "Butan", "bih" => "Bosna Hersek", "bolivia" => "Bolivya", "botswana" => "Botsvana", "brazil" => "Brezilya", "bulgaria" => "Bulgaristan", "burkinafaso" => "Burkina Faso", "burundi" => "Burundi", "cambodia" => "Kamboçya", "cameroon" => "Kamerun", "canada" => "Kanada", "caymanislands" => "Cayman Adaları", "chad" => "Çad", "colombia" => "Kolombiya", "congo" => "Kongo", "costarica" => "Kosto Rika", "croatia" => "Hırvatistan", "cyprus" => "Kıbrıs", "czech" => "Çekya", "djibouti" => "Cibuti", "dominicana" => "Dominik Cumhuriyeti", "easrrimor" => "Doğu Timor", "ekvador" => "Ekvador", "egpty" => "Mısır", "englad" => "İngiltere", "equatorialguinea" => "Ekvator Ginesi", "estonia" => "Estonya", "ethiopia" => "Etiyopya", "finland" => "Finlandiya", "france" => "Fransa", "frenchguiana" => "Fransız Guyanası", "gabon" => "Gabon", "gambia" => "Gambiya", "georgia" => "Gürcistan", "germany" => "Almanya", "ghana" => "Gana", "guadeloupe" => "Guadeloupe", "guatemala" => "Guatemala", "guinea" => "Gine", "guineabissau" => "Gine-Bissau", "guyana" => "Guyana", "haiti" => "Haiti", "honduras" => "Honduras", "hungary" => "Macaristan", "india" => "Hindistan", "indonesia" => "Endonezya", "iran" => "İran", "iraq" => "Irak", "ireland" => "İrlanda", "israel" => "İsrail", "italy" => "İtalya", "djibouti" => "Cibuti", "ivorycoast" => "Fildişi Sahili", "jamaica" => "Jamaika", "jordan" => "Ürdün", "kazakhstan" => "Kazakistan", "kenya" => "Kenya", "kuwait" => "Kuveyt", "laos" => "Laos", "latvia" => "Letonya", "lesotho" => "Lesotho", "libya" => "Libya", "lithuania" => "Litvanya", "luxembourg" => "Lüksemburg", "macau" => "Makao", "madagascar" => "Madagaskar", "malawi" => "Malavi", "malaysia" => "Malezya", "maldives" => "Maldivler", "mali" => "Mali", "mauritania" => "Moritanya", "mauritius" => "Mauritius", "mexico" => "Meksika", "moldova" => "Moldova", "mongolia" => "Moğolistan", "montenegro" => "Karadağ", "morocco" => "Fas", "mozambique" => "Mozambik", "myanmar" => "Myanmar", "namibia" => "Namibya", "nepal" => "Nepal", "netherlands" => "Hollanda", "newzealand" => "Yeni Zelanda", "nicaragua" => "Nikaragua", "nigeria" => "Nijerya", "oman" => "Umman", "pakistan" => "Pakistan", "panama" => "Panama", "papuanewguinea" => "Papua Yeni Gine", "paraguay" => "Paraguay", "peru" => "Peru", "philippines" => "Filipinler", "poland" => "Polonya", "portugal" => "Portekiz", "puertorico" => "Porto Riko", "qatar" => "Katar", "reunion" => "Réunion", "romania" => "Romanya", "russia" => "Rusya", "rwanda" => "Ruanda", "saintkittsandnevis" => "Saint Kitts ve Nevis", "saintlucia" => "Saint Lucia", "saintvincentandgrenadines" => "Saint Vincent ve Grenadinler", "salvador" => "Salvador", "saudiarabia" => "Suudi Arabistan", "senegal" => "Senegal", "serbia" => "Sırbistan", "slovakia" => "Slovakya", "slovenia" => "Slovenya", "somalia" => "Somali", "southafrica" => "Güney Afrika", "spain" => "İspanya", "srilanka" => "Sri Lanka", "sudan" => "Sudan", "suriname" => "Surinam", "swaziland" => "Esvati̇ni̇", "sweden" => "İsveç", "syria" => "Suriye", "taiwan" => "Tayvan", "tajikistan" => "Tacikistan", "tanzania" => "Tanzanya", "thailand" => "Tayland", "trinidad and tobago" => "Trinidad ve Tobago", "togo" => "Togo", "tunisia" => "Tunus", "turkey" => "Türkiye", "turkmenistan" => "Türkmenistan", "uae" => "Birleşik Arap Emirlikleri", "uganda" => "Uganda", "uruguay" => "Uruguay", "ukraine" => "Ukrayna", "usa" => "Amerika", "uzbekistan" => "Özbekistan", "venezuela" => "Venezuela", "vietnam" => "Vietnam", "yemen" => "Yemen", "zambia" => "Zambiya", "zimbabwe" => "Zimbabve" ); $json = json_decode(file_get_contents("https://5sim.biz/v1/guest/countries"), true); foreach ($json as $c => $ct){ if ($c !== "turkey") { array_push($countries, array( "name" => isset($tr[$c]) ? $tr[$c] : $ct["text_en"], "code" => $c )); } } return $countries; }
public function get_cheapest($country, $service) { $ci =& get_instance();
$ci->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));
$key = "$country-$service"; if (!$cheap = $ci->cache->get($key)) { $json = json_decode(file_get_contents("https://5sim.biz/v1/guest/prices?country=$country&product=$service"),true); $arr = array(); foreach ($json[$country][$service] as $operator => $data){ if($data["count"] > 8){ array_push($arr, array( $operator => $data["cost"] )); } }
usort($arr, function($a,$b){ return array_values($a)[0] > array_values($b)[0]; }); $cheap = $arr[0]; $ci->cache->save($key,$arr[0] , 900);
}
return $cheap; }
public function get_service_price($country, $service) { $json = json_decode(file_get_contents("https://5sim.biz/v1/guest/prices?country=$country&product=$product"), true); return max(array_column($json[$country][$service], 'cost')) . " RUB"; } public function get_services_by_country($country) { $services = array(); $api_key = get_instance()->config->item("fivesim_api_key"); $json = json_decode(file_get_contents("http://api1.5sim.biz/stubs/handler_api.php?api_key=$api_key&action=getNumbersStatus&country=$country"), true); foreach(array_keys($json) as $service) { if(strlen(explode("_",$service)[0]) > 2) { array_push($services, array( "id" => explode("_",$service)[0], "name" => explode("_",$service)[0]) ); } } return $services; } public function cancel_number($number_id) { $api_key = get_instance()->config->item("fivesim_api_key"); file_get_contents("http://api1.5sim.biz/stubs/handler_api.php?api_key={$api_key}&action=setStatus&id={$number_id}&status=-1"); } } ?>
|