1. Go to this page and download the library: Download fresh/sinch-bundle 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/ */
fresh / sinch-bundle example snippets
use Fresh\SinchBundle\Service\Sinch;
class Foo {
public function bar(Sinch $sinch) {
// Set the outbound number where you want to send the SMS
$messageId = $sinch->sendSMS('+13155555552', 'Your message');
// If success then the ID of sent message is returned (it is an integer value)
echo $messageId;
}
}
use Fresh\SinchBundle\Service\Sinch;
class Foo {
public function bar(Sinch $sinch) {
$messageId = 123456789; // The ID of Sinch message you get after successful SMS sending
// Status is a string with one of these values: pending, successful, faulted, unknown
$status = $sinch->getStatusOfSMS($messageId);
// Other helper methods, return true of false
$sinch->smsIsSentSuccessfully($messageId);
$sinch->smsIsPending($messageId);
$sinch->smsIsFaulted($messageId);
$sinch->smsInUnknownStatus($messageId);
}
}
use Fresh\SinchBundle\Exception\PaymentRequired\SinchPaymentRequiredException;
use Fresh\SinchBundle\Service\Sinch;
class Foo {
public function bar(Sinch $sinch) {
try {
$messageId = $sinch->sendSMS($phoneNumber, 'Your message');
// Some logic related to SMS processing...
} catch (SinchPaymentRequiredException $e) {
$logger->error('SMS was not sent. Looks like your Sinch account run out of money.');
// Here you can, for example, send urgent emails to admin users
// to notify that your Sinch account run out of money
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.