PHP code example of smslink / smsgateway

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

    

smslink / smsgateway example snippets

 php


/*
 *
 *     Require Autoload (change autoload.php path to match your project)
 *       
 */
\Connection;

/*
 * 
 * 
 *     Initialize SMS Gateway     
 *     
 *       Get your SMSLink / SMS Gateway Connection ID and Password from 
 *       https://www.smslink.ro/get-api-key/
 *       
 *       
 *       
 */

$Connection = new Connection();

$Connection->setConnectionCredentials("MyConnectionID", "MyConnectionPassword");

/*
 *     Sets the method in which the parameters are sent to SMS Gateway
 *
 *      1 for cURL GET  (make sure you have PHP cURL installed) (default and recommended)
 *      2 for cURL POST (make sure you have PHP cURL installed) 
 *      3 for file_get_contents ( 
     else echo "Message successfully sent with ID: ".$messageId.".<br />";

/*
 *     Sends SMS #2
 */
$messageId = $Connection->sendMessage("07xyzzzzzz", "My second hello world message.");

if ($messageId == false) echo "Message sent failed. Log: ".$Connection->getLastLogMessage().".<br />";
    else echo "Message successfully sent with ID: ".$messageId.".<br />";

/*
 *     Display account balance after sending SMS
 */
$accountBalance = $Connection->accountBalance();

echo "My Account Balance is: ".$accountBalance["national-SMS"]." national SMS, ".
          $accountBalance["international-SMS"]." national SMS<br />";

/*
 *     Display the communication log with SMSLink
*/
$Connection->displayLogMessages();