1. Go to this page and download the library: Download byjg/sms-client 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/ */
byjg / sms-client example snippets
// Register the provider and associate with a scheme
ProviderFactory::registerProvider(TwilioMessagingProvider::class);
// Create a provider
$provider = ProviderFactory::create(new Uri("twilio://$accountSid:$authToken@default"));
// Send a message
$response = $byjg->send("12221234567", (new \ByJG\SmsClient\Message("This is a test message")->withSender("+12223217654"));
// Check if the message was sent
if ($response->isSent()) {
echo "Message sent";
} else {
echo "Message not sent";
}
// Register the provider and associate with a scheme
ProviderFactory::registerProvider(TwilioMessagingProvider::class);
ProviderFactory::registerProvider(ByJGSmsProvider::class);
// Define the provider according to the country prefix
ProviderFactory::registerServices("twilio://accoundId:authToken@default", ["+1"]);
ProviderFactory::registerServices("byjg://username:password@default", ["+55"]);
// Send a message and select the provider according to the country prefix
$response = ProviderFactory::createAndSend("+5521900001234", (new \ByJG\SmsClient\Message("This is a test message")));
var_dump($response);
$response = ProviderFactory::createAndSend("+12221234567", (new \ByJG\SmsClient\Message("This is a test message"))->withSender("+12223217654"));
var_dump($response);
interface ProviderInterface
{
public static function schema();
public function setUp(Uri $uri);
public function send($to, Message $envelope): ReturnObject;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.