PHP code example of andreasnij / an-sms

1. Go to this page and download the library: Download andreasnij/an-sms 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/ */

    

andreasnij / an-sms example snippets


use AnSms\{
    SmsTransceiver,
    Message\Message,
    Message\PremiumMessage,
    Gateway\CellsyntGateway
};

$gateway = new CellsyntGateway('username', 'password');
$smsTransceiver = new SmsTransceiver($gateway);

// Send SMS
$message = Message::create('46700000000', 'Hello world!');
$smsTransceiver->sendMessage($message);

// Receive SMS
$receivedMessage = $smsTransceiver->receiveMessage($_GET);

// Receive SMS delivery report
$deliveryReport = $smsTransceiver->receiveDeliveryReport($_GET);

// Send Premium SMS
$premiumMessage = PremiumMessage::createFromIncomingMessage(
    'Thanks for your payment!', 
    5, 
    $receivedMessage
);
$smsTransceiver->sendMessage($premiumMessage);