1. Go to this page and download the library: Download octopush/sms-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
octopush / sms-api example snippets
$client = new Octopush\Client('*****@mail.com', '***API-KEY***');
$request = new Octopush\Request\SmsCampaign\SendSmsCampaignRequest();
$request->setRecipients([
[
'phone_number' => '+33600000000',
'param1' => 'Alex',
]
]);
$request->setSender('AnySender');
$request->setText('Hello {param1}, HAPPY NEW YEAR');
$request->setType(Octopush\Constant\TypeEnum::SMS_PREMIUM);
// ---------------------------------
// optional
// ---------------------------------
$request->setPurpose(Octopush\Request\SmsCampaign\SendSmsCampaignRequest::ALERT_TRANSACTIONAL);
$request->setWithReplies(false);
$date = new DateTimeImmutable('2021-01-01 00:01:00');
$isoDateWithTimeZone = $date->format(DATE_ISO8601); // 2021-01-01T00:01:00+0100
$request->setSendAt($isoDateWithTimeZone); // also works with "2021-01-01 00:01:00", (Central European TimeZone by default)
// ---------------------------------
$content = $client->send($request);
// ---------------------------------
// Result example:
// ---------------------------------
$client = new Octopush\Client('*****@mail.com', '***API-KEY***');
$request = new Octopush\Request\VocalCampaign\SendVocalCampaignRequest();
$request->setRecipients([
[
'phone_number' => '+33600000000',
]
]);
$request->setSender('AnySender');
$request->setText('Hello, HAPPY NEW YEAR');
$request->setType(Octopush\Constant\TypeEnum::VOCAL_SMS);
$request->setVoiceGender('female');
$request->setVoiceLanguage('fr-FR');
// ---------------------------------
// optional
// ---------------------------------
$request->setPurpose(Octopush\Request\VocalCampaign\SendVocalCampaignRequest::ALERT_TRANSACTIONAL);
$date = new DateTimeImmutable('2021-01-01 00:01:00');
$isoDateWithTimeZone = $date->format(DATE_ISO8601); // 2021-01-01T00:01:00+0100
$request->setSendAt($isoDateWithTimeZone); // also works with "2021-01-01 00:01:00", (Central European TimeZone by default)
// ---------------------------------
$content = $client->send($request);
// ---------------------------------
// Result example:
// ---------------------------------
$client = new Octopush\Client('*****@example.com', '***API-KEY***');
$request = new Octopush\Request\GetCreditRequest();
$request->setProductName(Octopush\Constant\TypeEnum::VOCAL_SMS);
$request->setCountryCode('FR');
$request->setWithDetails(true);
$content = $client->send($request);
// ---------------------------------
// Result example:
// ---------------------------------