abdallahmohammed / alsaad-php
PHP Client for using Alsaad's API.
Requires
- php: >=7.1
- php-http/guzzle6-adapter: ^1.0
- zendframework/zend-diactoros: ^2.2
Requires (Dev)
- estahn/phpunit-json-assertions: ^3.0.0
- php-http/mock-client: ^0.3.0
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2024-11-12 20:11:59 UTC
README
This library requires a minimum PHP version of 7.1
This is the PHP client library for use Alsaad2's API. To use this, you'll need a Alsaad2 account.
Installation
To install the PHP client library to your project, we recommend using Composer.
composer install abdallahmohammed/alsaad-php
Usage
If you're using Composer, make sure the autoloader is included in your project's bootstrap file:
require_once "vendor/autoload.php";
Create a client with your Username and Password:
$client = new Alsaad\Client([ 'username' => ALSAAD2_USERNAME, 'password' => ALSAAD2_PASSWORD, ]);
Examples
Sending a Message
To use Alsaad2's SMS API to send an SMS message, call the $client->message()->send()
method.
$message = $client->message()->send([ 'to' => ALSAAD2_TO, //can be array of numbers or string 'from' => ALSAAD2_SENDER, 'message' => 'Hello World' ]);
The API response data can be accessed as array properties of the message.
Accessing Response Data
When things go wrong, you'll receive an Exception. The exception class Alsaad\Client\Exception\Request
support an additional getEntity()
method which you can use in addition to getCode()
and getMessage()
to find out more about what went wrong. The entity returned will typically be an object related to the operation, or the response object from the API call.