Giter VIP home page Giter VIP logo

semaphore-client's Introduction

Semaphore Client

Semaphore Client is a PHP wrapper for the Semaphore SMS API

Table of Contents

Installation

composer require kickstartph/semaphore-client

Basic Usage

Sending Messages

<?php
    require_once( 'vendor/autoload.php' );

    use Semaphore\SemaphoreClient;
    $client = new SemaphoreClient( '{YOUR_API_KEY}', '{OPTIONAL_SENDER_NAME}' ); //Sender Name defaults to SEMAPHORE
    echo $client->send( '09991234567', 'Your message' );

The sender ID can be overridden through the client send command as well:

    echo $client->send( '09991234567', 'Your message', '{NEW_SENDER_ID}' );

Bulk messages (to up to 1000 numbers ) can also be sent through the same API call by providing a comma delimited set of numbers:

    echo $client->send( '09991234567,09997654321,', 'Your message' );

The response will contain a record for each message sent:

[
  {
    "message_id": 1234567,
    "user_id": 99556,
    "user": "[email protected]",
    "account_id": 90290,
    "account": "Your Account Name",
    "recipient": "09991234567",
    "message": "The message you sent",
    "sender_name": "SEMAPHORE",
    "network": "Globe",
    "status": "Queued",
    "type": "Single",
    "source": "Api",
    "created_at": "2016-01-01 00:01:01",
    "updated_at": "2016-01-01 00:01:01"
  }
]

Retrieving Messages

You can retrieve up to 100 sent messages at a time, with support for pagination by passing the optional $page variable:

    //Will return the results for page 2 of sent messages
    echo $client->messages( [ 'limit'=> 100 , 'page' => 2 ] ); 

####Messages by date range:

    //Use any date format str_to_time() supports
    echo $client->messages( 'startDate' => '2016-10-01, '2016-10-31' );  

####Messages by telco network:

    //Returns all messages sent to recipients on the Globe network
    echo $client->messages( ['globe'] ); 

####Supported Filters for retrieving messages

   $options = [
        'limit' => 100,
        'page' => 1,
        'sendername' => 'SEMAPHORE',
        'startDate' => '2016-01-01',
        'endDate' => '2016-02-01',
        'network' => 'globe',
        'status' => 'success'
   ];

Other functions

Below are other calls you can make: ####Account Information

    echo $client->account();
{
  "account_id": 12345,
  "account_name": "Your Organization",
  "status": "Active",
  "credit_balance": 5000
}

####Users

    echo $account->users();
[
  {
    "user_id": 12345,
    "email": "[email protected]",
    "role": "Owner"
  },
  {
    "user_id": 54321,
    "email": "[email protected]",
    "role": "User"
  }
]

####Sender Names

    echo $account->sendernames();
[
  {
    "name":"Semaphore",
    "status":"Active",
    "created":"2016-01-01 00:00:01"
  },
  {
    "name":"Kickstart",
    "status":"Active",
    "created":"2016-01-01 00:00:01""
  }
]

####Transactions

    echo $account->transactions();

semaphore-client's People

Contributors

aalabiso avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

semaphore-client's Issues

Latest version of API

The client isn't updated to v4 of the API. The latest version in this repository is the beta version of the API.

composer require kickstartph/semaphore-client multiple guzzlehttp issue

I was trying to install the client via composer and issued

composer require kickstartph/semaphore-client

but then It gave such statements/output

Using version ^0.5.0 for kickstartph/semaphore-client
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: guzzlehttp/guzzle[6.0.2, 6.3.3].
    - Can only install one of: guzzlehttp/guzzle[6.3.3, 6.0.2].
    - Can only install one of: guzzlehttp/guzzle[6.0.2, 6.3.3].
    - kickstartph/semaphore-client 0.5 requires guzzlehttp/guzzle 6.0.2 -> satisfiable by guzzlehttp/guzzle[6.0.2].
    - Installation request for kickstartph/semaphore-client ^0.5.0 -> satisfiable by kickstartph/semaphore-client[0.5].
    - Installation request for guzzlehttp/guzzle (locked at 6.3.3) -> satisfiable by guzzlehttp/guzzle[6.3.3].


Installation failed, reverting ./composer.json to its original content.

Now I do not know how to go with it.

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.