1. Go to this page and download the library: Download leandro980/skebby-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/ */
use Szopen\SkebbyBundle\Model\Manager\SkebbyManager;
// ..
/**
* @Route("/skebby/status", name="skebby.status")
*/
public function statusAction(SkebbyManager $skebby)
{
$s = $skebby->getStatus();
return $this->render('skebby/index.html.twig', [
'status' => $s,
]);
}
use Szopen\SkebbyBundle\Model\Manager\SkebbyManager;
use Szopen\SkebbyBundle\Model\Data\Recipient;
// ..
/**
* @Route("/skebby/send", name="skebby.sendsms")
*/
public function sendSmsAction(SkebbyManager $skebby)
{
$sms = $skebby->createDefaultSms('Hello, this is a test message',
[new Recipient('3331234567'), new Recipient('3207654321')]);
$response = $skebby->sendSms($sms);
return $this->render('skebby/index.html.twig', [
'response' => $response,
]);
}
use Szopen\SkebbyBundle\Model\Auth\AuthenticatorFactory;
//..
// Token authentication
$auth = AuthenticatorFactory::create('token')
// Session authentication
// $auth = AuthenticatorFactory::create('session')
// Used to authenticate in later API calls
$arrayAccess = $auth->login('username', 'password');
use Szopen\SkebbyBundle\Model\Auth\AuthenticatorFactory;
use Szopen\SkebbyBundle\Model\Client\UserClient;
//..
// Token authentication
$auth = AuthenticatorFactory::create('token')
$userClient = new UserClient('username', 'password', $auth);
use Szopen\SkebbyBundle\Model\Auth\AuthenticatorFactory;
use Szopen\SkebbyBundle\Model\Client\SmsClient;
use Szopen\SkebbyBundle\Model\Data\Recipient;
//..
// Token authentication
$auth = AuthenticatorFactory::create('token')
$smsClient = new SmsClient('username', 'password', $auth);
// Creating an sms
// You must choose which kind of SMS type to send
$sms = new Sms(Sms::SMS_CLASSIC_KEY);
// Add a message
// SmsClient choose wich kind of encoding to use, between UCS2 and GSM,
// authomatically parsing the message.
// It also counts chars available based on encoding, if the ength of the message exceeds the limit
// it raises a MessageLengthException
$sms->setMessage("Hello, this is a GSM encoded message");
// Substitutes message
$sms->setMessage("Hello, this is a UCS2 encoded message because of ç char");
// Set sender
// You can add sender only if your not using BASIC SMS and the aliasis registered to your account
$sms->setSender('YourAlias');
// Creating and adding a Recipient
// When you create a "Recipient" it parses the phone number, if it's not valid it raises
// a \libphonenumber\NumberParseException
$recipient = new Recipient("+393211234567");
$sms->addRecipient($recipient);
// Sending SMS
$smsResponse = $smsClient->sendSms($sms);
// You can choose to allow invalid recipients (that means that an invalid recipient
// won't block the entire operation) and if you want have the remaining sms and credit
$smsResponse = $smsClient->sendSms($sms,
true, // Allow invalid recipients
true, // Return remaining
true, // Return credit
);
use Szopen\SkebbyBundle\Model\Auth\AuthenticatorFactory;
use Szopen\SkebbyBundle\Model\Client\SmsClient;
use Szopen\SkebbyBundle\Model\Data\Group;
//..
// Creating and adding a recipient
$recipient = new Group("groupname");
$sms->addRecipient($recipient);
// Sending SMS
$smsResponse = $smsClient->sendGroupSms($sms);
// You can choose to allow invalid recipients (that means that an invalid recipient
// won't block the entire operation) and if you want have the remaining sms and credit
$smsResponse = $smsClient->sendGroupSms($sms,
true, // Allow invalid recipients
true, // Return remaining
true, // Return credit
);
// Adds a message with parameters
// The system recognizes the parameters in the text
$sms->setMessage('Hello ${name}, i know your surname is ${surname}');
// Creating and adding a Recipient with parameters
$recipient = new Recipient("+393211234567");
$recipient->addVariable('name', 'John');
$recipient->addVariable('surname', 'Dorian');
$sms->addRecipient($recipient);
// Sending SMS
// If just a Recipient does'nt contains all the parameters defined in message
// it raises a MissingParameterException
$smsResponse = $smsClient->sendSms($sms);
$sms = $skebby->createDefaultSms('Hello, this is a test message');
$sms->addRecipient(new Recipient("+393211234567"));
// You can also add recipients in constructor
$sms = $skebby->createDefaultSms('Hello, this is a test message',
[new Recipient('3331234567'), new Recipient('3207654321')]);
config/bundles.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.