Skip to content

Instantly share code, notes, and snippets.

@timiscoding
Created June 15, 2015 01:34
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 timiscoding/258cf5383af277d2bc43 to your computer and use it in GitHub Desktop.
Save timiscoding/258cf5383af277d2bc43 to your computer and use it in GitHub Desktop.
<?php
$myClientID = "myclientid";
$MyKey = "mykey";
$xml = file_get_contents("https://api.telstra.com/v1/oauth/token?client_id={$myClientID}&client_secret={$MyKey}&grant_type=client_credentials&scope=SMS");
$json_a = json_decode($xml, true);
$access_token = $json_a["access_token"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.telstra.com/v1/sms/messages");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$header= array ('Accept: application/json',
'content-type: application/json; charset=utf-8',
'Authorization: ' . sprintf('Bearer %1$s', $access_token));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$data= array('to' => '0412345678', 'body' => 'Hello');
$json_string = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS,$json_string);
$result = curl_exec($ch);
echo $result;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment