Documentation for the HTTP API for developers
Detailed documentation of all API: VIEW
If the function is not needed, we can add it for you.
PHP. Example API access via GET-request
/* * An example of service access to API. Example of getting a user’s balance is shown. * Access to another API functions is performing by the same way. * */ $url = "http://cp.uniqtele.com"; // service URL is assigned $timeout = 15; // assign time-out of answer in second // assign query parameter $params = http_build_query(array( 'r'=>'api/user_balance', // API function. Assigned in format "api/name_function" 'user'=>'user@gmail.com', // User’s login in system. It is align with login in 'apikey'=>'qwerty123' // API key. Assigned in user’s Personal Account )); $ch = curl_init(); // initialize CURL //задаем параметры CURL curl_setopt_array($ch, array( CURLOPT_URL => $url.'?'.$params, //point out URL to service and parameters CURLOPT_FAILONERROR => 1, //interrupt query in case of error CURLOPT_RETURNTRANSFER => 1, //return query result in variable CURLOPT_FOLLOWLOCATION => 1, //allow redirect CURLOPT_TIMEOUT => $timeout, //set time-out )); //receive answer to variable $result = curl_exec($ch); if($result) { //answer is in the form of JSON format. We should decode it in object presentation PHP $result = json_decode($result); //output status echo $result->status.'<br>'; //output sum on balance echo $result->balance; } else { //access to service is failed echo 'Access error to service!'; } curl_close($ch);
PHP. Example API access via POST-search
/* * An example of service access to API. An example of packet message sending is shown * */ $url = "http://cp.uniqtele.com"; // service URL is assigned $timeout = 15; // assign time-out of answer in second $func = 'msg_send_bulk'; //assign name of calling function. In this case - msg_send_bulk //form message packet $package = array( array( 'recipient'=>'39624456789', 'message'=>'The first test message. Urgent, with caption', 'sender'=>'MyCompany' ), array( 'recipient'=>'39624746363', 'message'=>'Второе тестовое сообщение. Обычное, с custom_id', 'custom_id'=>'111' ), array( 'recipient'=>'39536788463', 'message'=>'The second test message. Usual, with custom_id', 'custom_id'=>'222' ) ); $rawData = json_encode($package); //code packet in JSON $ch = curl_init(); //initialize cURL //set parameters CURL curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_FAILONERROR => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_TIMEOUT => $timeout, CURLOPT_CONNECTTIMEOUT => 0, CURLOPT_POST => 1, //send by the POST-method –just in a such way you can send a big packet CURLOPT_POSTFIELDS => array( 'r'=>'api/'.$func, //assign calling function 'user'=>'some@mail.com', //user’s login 'apikey'=>'ABC123', //API-key 'messages'=>$rawData) //message massive )); //receive an answer to variable $result = curl_exec($ch); if($result) { //a line of UTF-8 format – delete from it BOM-sequence $__BOM = pack('CCC', 239, 187, 191); while(0 === strpos($result, $__BOM)) $result = substr($result, 3); //answer is in the form of JSON format. We should decode it in object presentation PHP $result = json_decode($result); //output status echo $result->status.'<br>'; //output dump of answer echo '<plaintext>'.iconv('utf-8','windows-1251',print_r($result, true)); } else { //an access to service is failed echo 'Access error to service!'; } curl_close($ch);