Git Product home page Git Product logo

nexmo's Introduction

nexmo

PHP client to interact with Nexmo APIs

This library was developed as part of a tutorial, you can go through the tutorial starting at:

Creating a PHP Nexmo API Client using Guzzle Web Service Client โ€“ Part 1

This library now covers all RESTful outbound APIs from Nexmo, so whether you're interested in the tutorial or not you're welcome to use the library for integration with Nexmo.

Install

Installation is easy with composer. Just add "fillup/nexmo": "dev-master" to your composer.json require section and update.

Usage / Example

All classes are in the Nexmo\ namespce:

use Nexmo\Developer;
use Nexmo\Insight;
use Nexmo\Sms;
use Nexmo\Verify;
use Nexmo\Voice;

/**
 * Load config, expecting an array with:
 * api_key, api_secret, to, from, text
 */
$config = include __DIR__.'/../../config-local.php';

/**
 * Get an SMS client object
 */
$sms = new Sms($config);

/**
 * Send a message
 */
$results = $sms->send([
    'from' => $config['from'],
    'to' => $config['to'],
    'text' => $config['text'],
]);

/**
 * Dump out results
 */
print_r($results);
// Array
// (
//    [statusCode] => 200
//    [message-count] => 1
//    [messages] => Array
// (
//    [0] => Array
//    (
//        [to] => 14085559876
//                    [message-id] => 0300000071BCAA3C
//                    [status] => 0
//                    [remaining-balance] => 15.23280000
//                    [message-price] => 0.00480000
//                    [network] => US-VOIP
//                )
// 
//        )
// 
// )

All API calls require an api_key and api_secret. Best practice would be to keep this out of your code an in some sort of configuration file or environment variable that does not go into your source code. Just pass an array with keys for api_key and api_secret to the constructor of each class like in the example above.

nexmo's People

Contributors

fillup avatar tjlytle avatar

Watchers

 avatar  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.