Giter Club home page Giter Club logo

smslink-smsgateway-composer's Introduction

Integration of SMSLink - SMS Gateway (HTTP) using Composer (Dependency Manager for PHP)

This is an integration example for sending SMS using SMSLink.ro API, called SMS Gateway. SMSLink.ro allows you to send SMS to all mobile networks in Romania and also to more than 168 countries and more than 1000 mobile operators worldwide.

Installation

Using Composer (Dependency Manager for PHP)

$ composer require smslink/smsgateway

smslink/smsgateway Package on Packagist - The PHP Package Repository

Requirements

  1. Create an account on SMSLink.ro
  2. Create a SMS Gateway connection at SMSLink.ro / SMS Gateway / Configuration & Settings. Each SMS Gateway connection is a pair of Connection ID and Password.

Supported Functions

  1. $Connection->sendMessage() - sends an SMS
  2. $Connection->accountBalance() - retrieve SMSLink account balance

Features

  1. Supports HTTP and HTTPS protocols
  2. Supports PHP cURL GET, PHP cURL POST and file_get_contents()

System Requirements

  • PHP 5 or greater with PHP cURL library or file_get_contents with allow_url_fopen to be set to 1 in php.ini
  • Composer - Dependency Manager for PHP
  • smslink/smsgateway Package on Packagist - The PHP Package Repository

Usage Example using Composer

<?php

/*
 *
 *     Require Autoload (change autoload.php path to match your project)
 *       
 */
require_once 'vendor/autoload.php';

/*
 *
 *     Include the SMSLink\SMSGateway\Connection namespace
 *       
 */

use SMSLink\SMSGateway\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 (requires allow_url_fopen to be set to 1 in php.ini) 
 *           (recommended if you do not have PHP cURL installed)
 */
$Connection->setRequestMethod(1);      

/*
 *     Sets the protocol that will be used by SMS Gateway (HTTPS or HTTP).
 */
$Connection->setProtocol("HTTPS");

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

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

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

if ($messageId == false) echo "Message sent failed. Log: ".$Connection->getLastLogMessage().".<br />"; 
     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();

?> 

Usage Example without using Composer

SMSLink.ro SMS Gateway can also be used without Composer. For using SMSLink SMS Gateway without Composer see the following example.

Documentation

The complete documentation of the SMSLink - SMS Gateway API can be found here, describing all available APIs (HTTP GET / POST, SOAP / WSDL, JSON and more).

Additional modules and integrations

SMSLink also provides modules for major eCommerce platforms (on-premise & on-demand), integrations using Microsoft Power Automate, Zapier or Integromat and many other useful features. Read more about all available features here.

Support

For technical support inquiries contact us at [email protected] or by using any other available method described here.

smslink-smsgateway-composer's People

Contributors

smslink avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.