2017 © Pedro Peláez
 

sdk sdk

SDK for FastSMS api.

image

fastsms/sdk

SDK for FastSMS api.

  • Wednesday, February 28, 2018
  • by ruslan.tabachuk
  • Repository
  • 8 Watchers
  • 4 Stars
  • 19,591 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 10 Versions
  • 11 % Grown

The README.md

PHP SDK for FastSMS API.

PHP library to access FastSMS api. Thank you for choosing FastSMSbr/ Latest Stable Version Total Downloads Latest Unstable Version License Build Status, (*1)

DIRECTORY STRUCTURE

src/                 core wrapper code
tests/               tests of the core wrapper code

REQUIREMENTS

The minimum requirement by FastSMS wrapper is that your Web server supports PHP 5.4., (*2)

DOCUMENTATION

FastSMS has a Knowledge Base and a Developer Zone which cover every detail of FastSMS API., (*3)

INSTALLATION

Add to composer, (*4)

"require": {
    ...
    "fastsms/sdk": "*",
    ...
}

USAGE

Init SDK

Your token (found in your settings within NetMessenger), (*5)

$FastSMS = new FastSMS\Client('your token');

or, (*6)

use FastSMS\Client;
...
$FastSMS = new Client('your token');
...

Wrap errors

List all API codes found in docs, (*7)

use FastSMS\Client;
use FastSMS\Exception\ApiException;
...
$client = new Client('your token');
try {
    $credits = $client->credits->getBalance();
} catch (ApiException $aex) {
    echo 'API error #' . $aex->getCode() . ': ' . $aex->getMessage();
} catch (Exception $ex) {
    echo $ex->getMessage();
}

Actions

Credits

Checks your current credit balance., (*8)

$credits = $client->credits->balance; //return float val
echo number_format($credits, 2); //example show 1,000.00

Send

Sends a message. More information read this, (*9)

...
use FastSMS\Model\Message;
...
// Init Message data
$data = [
    //set
    'destinationAddress' => 'Phone number or multiple numbers in array',
    //or
    'list' => 'Your contacts list',
    //or
    'group' => 'Your contacts group'

    'sourceAddress' => 'Your Source Address',
    'body' => 'Message Body', //Note: max 459 characters
    //optionals
    'scheduleDate' => time() + 7200, //now + 2h
    'validityPeriod' => 3600 * 6, //maximum 86400 = 24 hours
    'sourceTON' => 1, //The Type Of Number for the source address (1 for international, 5 for alphanumeric)
];
$result = $client->message->send($data);

Check message status

Check send message status. More information read this, (*10)

$result = $client->message->status($messageId);// Message Id must be integer

Create User

Create new child user. Only possible if you are an admin user. More information read this, (*11)

...
use FastSMS\Model\User;
// Init user data
$data = [
    'childUsername' => 'Username',
    'childPassword' => 'Password',
    'accessLevel' => 'Normal', //or 'Admin'
    'firstName' => 'John',
    'lastName' => 'Doe',
    'email' => 'user@example.com',
    'credits' => 100,
    //optionals
    'telephone' => 15417543010, // integer
    'creditReminder' => 10,
    'alert' => 5, //5 days
];
$result = $client->user->create($data);

Update Credits

Transfer credits to/from a child user. Only possible if you are an admin user. More information read this, (*12)

...
use FastSMS\Model\User;
// Init update user data
$data = [
    'childUsername' => 'Exist Username',
    'quantity' => -5, //The amount of credits to transfer.
];
$user = new User($data);
$result = $client->user->update($user);

Reports

Retrieve the data from a report. More information read this Aviable types: - ArchivedMessages - ArchivedMessagesWithBodies - ArchivedMessagingSummary - BackgroundSends - InboundMessages - KeywordMessageList - Messages - MessagesWithBodies - SendsByDistributionList - Usage, (*13)

...
use FastSMS\Model\Report;
...
// Init Report params
$data = [
    'reportType' => 'Messages',
    'from' => time() - 3600 * 24 * 30,
    'to' => time()
];
// Get report
$result = $client->report->get($data);

Add contact(s)

Create contact(s). More information read this, (*14)

...
use FastSMS\Model\Contact;
...
// Init Contacts data
$data = [
    'contacts' => [
        ['name' => 'John Doe 1', 'number' => 15417543011, 'email' => 'john.doe.1@example.com'],
        ['name' => 'John Doe 2', 'number' => 15417543012, 'email' => 'john.doe.2@example.com'],
        ['name' => 'John Doe 3', 'number' => 15417543013, 'email' => 'john.doe.3@example.com'],
    ],
    'ignoreDupes' => false,
    'overwriteDupes' => true
];
// Get report
$result = $client->contact->create($data);

Delete All Contacts

More information read this, (*15)

...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->contact->deleteAll();

Delete All Groups

More information read this, (*16)

...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->group->deleteAll();

Empty Group

Remove all contacts from the specified group. More information read this, (*17)

...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->group->empty('Group Name');

Delete Group

Delete the specified group. More information read this, (*18)

...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->group->delete('Group Name');

The Versions

28/02 2018

dev-master

9999999-dev

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by FastSMS

api newsletter sms sdk fastsms

12/04 2016

v1.1.2

1.1.2.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by FastSMS

api newsletter sms sdk fastsms

27/01 2016

v1.1.1

1.1.1.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by FastSMS

api newsletter sms sdk fastsms

27/01 2016

v1.1.0

1.1.0.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by FastSMS

api newsletter sms sdk fastsms

02/10 2015

1.0.3

1.0.3.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by FastSMS

api newsletter sms sdk fastsms

18/06 2015

1.0.2

1.0.2.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by Ruslan Tabachuk

api newsletter sms sdk fastsms

18/06 2015

1.0.1

1.0.1.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Ruslan Tabachuk

api newsletter sms sdk fastsms

18/06 2015

1.0.0

1.0.0.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Ruslan Tabachuk

api newsletter sms sdk fastsms

12/06 2015

v0.2.1

0.2.1.0

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Ruslan Tabachuk

api newsletter sms sdk fastsms

27/05 2015

0.1.0-alpha1

0.1.0.0-alpha1

SDK for FastSMS api.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

by Ruslan Tabachuk

api newsletter sms sdk fastsms