zerosdev / kirimwa-php-client
Client SDK Library for Kirimwa.cloud
v1.1.0
2021-06-04 14:51 UTC
Requires
- php: >=5.6
- ext-json: *
- guzzlehttp/guzzle: ^6.0 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^7
README
Client SDK Library for Kirimwa.cloud Server Application
Requirements
- PHP 5.6+
- PHP JSON Extension
- Guzzle, PHP HTTP Client
Installation
- Run command
composer require zerosdev/kirimwa-php-client
The following steps only needed if you are using Laravel
For installation on Laravel 5.5+, SKIP steps 2 & 3 because we have used the Package Discovery feature, Laravel will automatically register the Service Provider and Alias during installation.
- Open your config/app.php and add this code to the providers array, it will looks like:
'providers' => [
// other providers
ZerosDev\KirimWA\Laravel\ServiceProvider::class,
],
- Add this code to your class aliases array
'aliases' => [
// other aliases
'KirimWA' => ZerosDev\KirimWA\Laravel\Facade::class,
],
- Run command
composer dump-autoload
- Then
php artisan vendor:publish --provider="ZerosDev\KirimWA\Laravel\ServiceProvider"
- Edit config/kirimwa.php and put your KirimWA Server information like API host and sender list
Basic Usage
Laravel Usage
<?php namespace App\Http\Controllers; use KirimWA; class YourController extends Controller { public function index() { KirimWA::sendText('6281234567890', 'This is message to be sent'); if( KirimWA::hasError() ) { dd(KirimWA::error()); } else { dd(KirimWA::response()); } } }
Non-Laravel Usage
<?php require 'path/to/your/vendor/autoload.php'; use ZerosDev\KirimWA\Client; use ZerosDev\KirimWA\Config; Config::apply([ 'default_host' => 'http://yourwaserver.com', 'senders' => [ '6281234567890' => [ 'host' => ':3001', // just place port number to follow 'default_host' 'key' => 'your api key here' ], '6280987654321' => [ 'host' => 'http://youranotherwaserver.com:3002', // or place full API host with port to use different host than the 'default_host' 'key' => 'your api key here' ], ] ]); $kirimwa = new Client(); $kirimwa->sendText('6281234567890', 'This is message to be sent'); if( $kirimwa->hasError() ) { echo $kirimwa->error(); } else { echo $kirimwa->response(); }