/php-smsintel-api

A PHP wrapper for the SmsIntel API. Provides one interface for both XML and JSON API requests.

Primary LanguagePHPMIT LicenseMIT

SmsIntel PHP Api

SmsIntel PHP Api

Library provides common interface for making requests to both XML and JSON smsintel API.

Dependencies

Library requires CURL extension and PHP 5.5.9 or above.

Installation

Via Composer:

composer require seregazhuk/smsintel-api

Quick Start

// You may need to amend this path to locate composer's autoloader
require('vendor/autoload.php'); 

use seregazhuk\SmsIntel\SmsIntel;

$sender = SmsIntel::create('login', 'password');

// send sms
$result = $sender->send('phoneNumber', 'From', 'Your message text');

Sending messages

To send message to one phone number:

$result = $sender->send('phoneNumber', 'From', 'Your message text');

You can pass an array of phones:

$phones = [
 '79999999999'
 '79999999991'
 '79999999992'
];
$result = $sender->send($phones, 'From', 'Your message text');

Cancel sms by id:

$result = $sender->cancel($smsId);

Request a source name:

$result = $sender->requestSource('FromPHP');

Groups and contacts

Get contact info by phone number:

$contact = $sender->getPhoneInfo('79999999999');

Get all contacts:

$contacts = $sender->getContacts();

Contacts for specific group:

$groupId = 1;
$contacts = $sender->getContacts($groupId);

Contacts by phone number:

$phone = '79999999999';
$contacts = $sender->getContacts(null, $phone);

// or with group:
$groupId = 1;
$contacts = $sender->getContacts($groupId, $phone);

Create a new contact:

$contactInfo = [
	'idGroup' => 1 // required
	'phone'   => '79999999999' // required
	'f'       => 'Second Name',
	'i'       => 'First Name',
	'o'       => 'Middle Name',
	'bday'    => 'YYYY-mm-dd',
	'sex'     => 1 // 1 - male, 2 - female
];
$result = $sender->addContact($contactInfo);

Remove contact by phone number:

$sender->removeContact('79999999999');

You can pass optionally group id:

$groupId = 1;
$sender->removeContact('79999999999', $groupId);

Get all groups:

$groups = $send->getGroups();

Get group by id or name:

$groups = $sender->getGroups($groupId);
$groups = $sender->getGroups(null, $groupName);

Create a new group of contacts:

$result = $sender->createGroup('NewGroup');

Edit group name by id:

$result = $sender->editGroup($newName, $groupId);

Account

Get account info:

$result = $sender->getAccountInfo();

Get balance:

$result = $sender->getBalance();

Use discount coupon:

$result = $sender->checkCoupon('couponCode');

Only check discount coupon:

$result = $sender->checkCoupon('couponCode', false);

Reports

Get report for period by phone number:

$result = $sender->getReportByNumber($dateFrom, $dateTo, '79999999999');

Get report for period and for all numbers:

$result = $sender->getReportByNumber($dateFrom, $dateTo);

Get report by smsId:

$result = $sender->getReportBySms($smsId);

Get report for period by source:

$result = $sender->getReportBySource($dateFrom, $dateTo, 'FromPHP');

Get report for period for all sources:

$result = $sender->getReportBySource($dateFrom, $dateTo);

How can I thank you?

Why not star the github repo? I'd love the attention!

Thanks!