Created
November 27, 2014 15:57
-
-
Save DJM0/0dc424b417c5ca0ad851 to your computer and use it in GitHub Desktop.
Sipcentric API originate call example in PHP5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$username = "username"; // Sipcentric API username | |
$password = "password"; // Sipcentric API password | |
$customer = "me"; // Enter your customer number here | |
$dial = "0123456789"; // Enter a number to dial | |
// Change number at the end to the one of your extension (this one is my extension 002535) | |
$extension = "https://pbx.sipcentric.com/api/v1/customers/" . $customer . "/endpoints/2535"; | |
// Everything below is fine to leave... | |
$data = array( | |
"type" => "call", | |
"endpoint" => $extension, | |
"to" => $dial | |
); | |
$json = json_encode($data); | |
echo "Calling " . $dial . " from " . $extension; | |
$request = curl_init("https://pbx.sipcentric.com/api/v1/customers/" . $customer . "/calls"); | |
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($request, CURLOPT_USERPWD, $username . ":" . $password); | |
curl_setopt($request, CURLOPT_POSTFIELDS, $json); | |
curl_setopt($request, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($request, CURLOPT_HTTPHEADER, array( | |
"Content-Type: application/json", | |
"Content-Length: " . strlen($json)) | |
); | |
$result = curl_exec($request); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment