Skip to content

Instantly share code, notes, and snippets.

@developersteve
Created August 17, 2018 01:24
Show Gist options
  • Save developersteve/1fc9e979d2a87bd55903ff4be870a8db to your computer and use it in GitHub Desktop.
Save developersteve/1fc9e979d2a87bd55903ff4be870a8db to your computer and use it in GitHub Desktop.
MessagingAPI PHP example
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new Telstra_Messaging\Api\AuthenticationApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$client_id = ""; // string |
$client_secret = ""; // string |
$grant_type = "client_credentials"; // string |
$result = $apiInstance->authToken($client_id, $client_secret, $grant_type);
$config = Telstra_Messaging\Configuration::getDefaultConfiguration()->setAccessToken($result['access_token']);
// get provision
$apiInstance = new Telstra_Messaging\Api\ProvisioningApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$arr = array(
"active_days" => 30
);
// create number
$body = new \Telstra_Messaging\Model\ProvisionNumberRequest($arr);
$result = $apiInstance->createSubscription($body);
print_r($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment