Client SDK Library for Kirimwa.cloud Server Application
- PHP 5.6+
- PHP JSON Extension
- Guzzle, PHP HTTP Client
- Run command
composer require zerosdev/kirimwa-php-client
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
<?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());
}
}
}
<?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();
}