2017 © Pedro PelĂĄez
 

library iletimerkezi-php

iletimerkezi.com php client library

image

engin/iletimerkezi-php

iletimerkezi.com php client library

  • Monday, May 29, 2017
  • by engin
  • Repository
  • 3 Watchers
  • 1 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

iletimerkezi-php

iletimerkezi.com PHP Client library Build Status, (*1)

Road map for v01:

  • send sms
  • deal with errors
  • query prev. sended sms reports
  • query account balance
  • query available senders (aka originator)

Examples

Let's configure and initialize a client:

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

use Emarka\Sms\Client;

$client = Client::createClient([
    'api_key'        => '<xyz-etc>', // generate api key / secret pair from account -> settings
    'secret'         => '<secret>', // don't ever expose this guy.
    'sender'         => 'Engin Dumlu',
    'local_timezone' => 'Europe/Istanbul',
]);

Sending simple message - examples

  • simple
$client->send('5321112233', 'Hello World'); // this is the most basic usage of sending sms
  • simple, to multiple recipients
$client->send(['5321112233', '5321112234'], 'Hello World'); // same text to multiple recipients
  • multiple recipients each with different text
$client->send(
    [
        '05321112233' => 'Hello World',
        '05321112234' => 'Selam DĂŒnya',
        '05321112235' => 'äœ ć„œïŒŒäž–ç•Œ'
    ],  // recipients with messages
    null, //
    [
        'encoding' => 'unicode', // text encoding
    ]
);

Optional parameters

Message encoding: can we any of gsm8 | turkish | unicode. Or leave it off for account default., (*2)

$client->send('5321112233', 'TĂŒrkçe sms göndermek bu kadar zor olmamalı.', [
    'encoding' => 'turkish', // text encoding
]); 

Future delivery: can be any future date [TODO: unified and simple date parsing ], (*3)

$client->send('5321112233', 'Meet me at the chinese restaurant!', [
    'send_at' => '2 hours later', // deliver sms at 2 hours later
]); 

Change the sender name [Aka: originator], (*4)

$client->send('5321112233', 'Authentication verify. Please enter the code: '.mt_rand(9999, 99999), [
    'sender' => 'OTP Verify', // change the sender
]); 

Basic reporting with tracking id (a.k.a order_id), (*5)

$tracking_id = $client->send(['5321112233', '5321112234', '5321112234'], 'Hello reporting..');

$reporter    = $client->reportIterator($tracking_id);
echo 'report id: '.         $reporter->getId().PHP_EOL;
echo 'sender: '.            $reporter->sender().PHP_EOL;
echo 'report status: '.     $reporter->status()->description().PHP_EOL;
echo 'total recipients: '.  $reporter->totalRecipients().PHP_EOL;
echo 'total delivered: '.   $reporter->totalDelivered().PHP_EOL;
echo 'total failed: '.      $reporter->totalFailed().PHP_EOL;
echo 'total enroute: '.     $reporter->totalEnroute().PHP_EOL;
echo 'send at: '.           $reporter->sendAt().PHP_EOL;
echo 'submit at: '.         $reporter->submitAt().PHP_EOL;

Iterating over recipient list, (*6)

$tracking_id = $client->send('5321112233', 'Hello World'); // later, you can query delivery status of the messages

$reporter = $client->reportIterator($tracking_id);

while ($reporter->next()) {
    $reporter->each(function ($number, Emarka\Sms\StateInterface $state) {
        echo $number.' -> '.$state->state().' / '.$state->description().PHP_EOL;
    });
}

``` +905321131913 -> TEXT_ENROUTE / Message is being sent or waiting for delivery report., (*7)



Available originators (sender names) ```php $senders = $client->originators(); print_r($senders);

Sample output:, (*8)

Array
(
    [0] => Engin Dumlu
)

Query current balance of the account, (*9)

echo $client->balance()->humanReadable();

Sample output:, (*10)

973 TL

Blacklist operations

Add number to blacklist, (*11)

$status = $client->addToBlacklist('5321112233');
if ($status->isSuccess()) {
    // number added to blacklist
} else {
    // something went wrong;
    echo $status->description().PHP_EOL;
}

Remove number from blacklist, (*12)

$status = $client->removeFromBlacklist('5321112233');
if ($status->isSuccess()) {
    // number removed from blacklist
} else {
    // something went wrong;
    echo $status->description().PHP_EOL;
}

Fetch the blackedlist, (*13)

$client->blacklistIterator()->each(function ($number) {
    echo $number.' is in the blacklist.'.PHP_EOL;
});

Open source

We love getting feedback and contributions from the opensource community Feel free to contribute., (*14)

The Versions

29/05 2017

dev-development

dev-development

iletimerkezi.com php client library

  Sources   Download

GPL-3.0

The Requires

  • php ^5.3.2 || ^7.0

 

The Development Requires

by Engin Dumlu

26/01 2017

dev-master

9999999-dev https://github.com/roadrunner/iletimerkezi-php

iletimerkezi.com php client library

  Sources   Download

GPL-3.0

The Requires

  • php ^5.3.2 || ^7.0

 

The Development Requires

by Engin Dumlu

sms iletimerkezi