function zadarma_callback_s($from, $to) { include_once 'inc/zadarma-user-api-v1/lib/Client.php'; $key = get_option('zadarma_api_key_s'); define('KEY', $key); $secret = get_option('zadarma_api_secret_s'); define('SECRET', $secret); $params = array('from' => $from, 'to' => $to); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/request/callback/', $params); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { return $answerObject; } else { return $answerObject->message; } return; }
<?php include_once 'include.php'; $params = array('number' => '442037691880', 'message' => 'Hello from Zadarma API'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/sms/send/', $params, 'post'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo 'Messages: ' . $answerObject->messages . '<br/>'; echo 'Cost: ' . $answerObject->cost . ' ' . $answerObject->currency . '<br/>'; } else { echo $answerObject->message; }
<?php include_once 'include.php'; $params = array('from' => '442037691880', 'to' => '442037691881'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/request/callback/', $params); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { print_r($answerObject); } else { echo $answerObject->message; }
<?php include_once 'include.php'; $params = array('number' => '442037691880'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/info/price/', $params); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo 'Price - ' . $answerObject->info->price; echo '<h4>Full info</h4>'; print_r($answerObject->info); }
<?php include_once 'include.php'; $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/pbx/internal/100/status/'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo "<pre>"; print_r($answerObject->is_online); echo "</pre>"; }
<?php include_once 'include.php'; $params = array('start' => '2015-01-01 00:00:00', 'end' => '2015-01-31 00:00:00'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/statistics/', $params); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { print_r($answerObject->stats); } else { echo $answerObject->message; }
<?php include_once 'include.php'; $params = array('id' => 'YOURPBXNUMBER', 'status' => 'on'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/pbx/internal/recording/', $params, 'put'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo "Number: " . $answerObject->internal_number . "<br/>"; echo "Status: " . $answerObject->recording; } else { echo $answerObject->message; }
<?php include_once 'include.php'; $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/sip/'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { print_r($answerObject->sips); }
<?php include_once 'include.php'; $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/info/balance/'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo 'Your balance is ' . $answerObject->balance . ' ' . $answerObject->currency; } /* echo 'Limits: '; print_r($zd->getLimits()); */
<?php include_once 'include.php'; $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/direct_numbers/'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { print_r($answerObject->info); } else { echo $answerObject->message; }
<?php include_once 'include.php'; $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/tariff/'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { print_r($answer); } else { echo $answerObject->message; }
<?php include_once 'include.php'; $params = array('start' => '2016-09-01 00:00:00', 'end' => '2016-09-30 23:59:59'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/statistics/callback_widget/', $params); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { print_r($answerObject->stats); } else { echo $answerObject->message; }
<?php include_once 'include.php'; $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/pbx/internal/'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo "<pre>"; print_r($answerObject->numbers); echo "</pre>"; }
<?php include_once 'include.php'; $params = array('id' => 'YOURSIP', 'type' => 'phone', 'number' => '442037691880'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/sip/redirection/', $params, 'put'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo 'Redirection on your SIP "' . $answerObject->sip . " has been changed to " . $answerObject->destination . "."; } else { echo $answerObject->message; }
<?php include_once 'include.php'; $params = array('id' => 'YOURSIP', 'number' => '442037691880'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/sip/callerid/', $params, 'put'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo 'Your Caller ID was successfully changed.'; } else { echo $answerObject->message; }
<?php include_once 'include.php'; $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/sip/00001/status/'); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { print_r($answerObject->is_online); }
<?php include_once 'include.php'; $params = array('call_id' => '1458832388.1585217'); $zd = new \Zadarma_API\Client(KEY, SECRET); $answer = $zd->call('/v1/pbx/record/request/', $params); $answerObject = json_decode($answer); if ($answerObject->status == 'success') { echo "<pre>"; print_r($answerObject); echo "</pre>"; } else { echo $answerObject->message; }