Skip to content

Instantly share code, notes, and snippets.

@DJM0
Created November 27, 2014 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DJM0/0dc424b417c5ca0ad851 to your computer and use it in GitHub Desktop.
Save DJM0/0dc424b417c5ca0ad851 to your computer and use it in GitHub Desktop.
Sipcentric API originate call example in PHP5
<?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