Sample code to lookup country code against market view and use multiple parameters such as CLI , NONE CLI , TDM and more:
<?php // my login in TCXC $api_login ="ENTER YOUR BUYER USER NAME HERE"; //my API key $api_key = "ENTER YOUR BUYER API KEY"; // initialising CURL $ch = curl_init(); //controller is a script name, so in case lookup.php controller is lookup $controller = "lookup"; //unix timestamp to ensure that signature will be valid temporary $ts = time(); //compose signature concatenating controller api_key api_login and unix timestamp $signature = hash( 'sha256', $controller . $api_key . $api_login . $ts); $params = array( 'ts' => $ts, //provide TS 'signature' => $signature, 'api_login' => $api_login, 'webapi' => '1', // required field 'prefix' => '962', // same parameters as web portal accepts 'searchform' => '1', // same parameters as web portal accepts 'type' => 'CLI', // same parameters as web portal accepts //... ); //query against api. URL curl_setopt($ch, CURLOPT_URL,"https://members.telecomsxchange.com/$controller.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec ($ch); curl_close ($ch); //analyze JSON output echo "$server_output"; ?>
Sample JSON Response:
[
{
"prefix":"1",
"vendor_name":"testseller",
"connection_name":"tollfree",
"i_tariff":"145",
"daily_asr":44,
"weekly_asr":64,
"daily_acd":4:32,
"weekly_acd":1,
"daily_minutes":0,
"weekly_minutes":0,
"stats_time":"2017-02-27 02:30:02",
"i_connection":"144",
"effective_from":"04\/13\/16 4:45PM",
"price_1":"0.0023",
"price_n":"0.0023",
"interval_1":"6",
"interval_n":"6",
"i_vendor":"114",
"capacity_limit":"20",
"i_rate":"6483882",
"forbidden":"0",
"discontinued":"0",
"route_type":"CLI",
"seller_registration_date":"2013-07-25 13:06:52",
"country_code":"",
"country_name":"Usa",
"description":"Other",
"commision_percent":"0",
"seller_avg_rating":5,
"seller_reviews":55,
"rateid":6483882
},
{
"prefix":"1",
"vendor_name":"Twilio",
"connection_name":"Elastic SIP Trunking",
"i_tariff":"186",
"daily_asr":42,
"weekly_asr":63,
"daily_acd":8:10,
"weekly_acd":13:00,
"daily_minutes":99999,
"weekly_minutes":20003003,
"stats_time":"0000-00-00 00:00:00",
"i_connection":"185",
"effective_from":"10\/05\/16 2:44PM",
"price_1":"0.01",
"price_n":"0.01",
"interval_1":"1",
"interval_n":"1",
"i_vendor":"134",
"capacity_limit":"111",
"i_rate":"6483942",
"forbidden":"0",
"discontinued":"0",
"route_type":"CLI",
"seller_registration_date":"2013-11-12 13:57:27",
"country_code":"",
"country_name":"Usa",
"description":"Other",
"commision_percent":"0",
"seller_avg_rating":5,
"seller_reviews":0,
"rateid":6483942
}
]
