1. Go to this page and download the library: Download kiwari/kiwari-bot-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kiwari / kiwari-bot-sdk example snippets
= new \Kiwari\Kiwari('your-access-token-here');
$bot->enableLog(true); // you can enable log, the log file is inside your tmp
//now you need to run the bot
$bot->run();
//and now you can get the incomming data by using :
$sender = $bot->getSender();
/**
* to get the sender
* example data for method : $bot->getSender()
*
* {
* "id": 287,
* "phone_number": "+6285123123123",
* "fullname": "Jarjit Singh",
* "qiscus_email": "[email protected]",
* "qiscus_id": 11
* }
*/
$myAccount = $bot->getMyAccount();
/**
* to get the my account or the bot
* example data for method : $bot->getMyAccount()
*
* {
* "id": 22,
* "phone_number": "+628681234567",
* "fullname": "Cuti Bot",
* "qiscus_email": "[email protected]"
* }
*/
$room = $bot->getChatRoom();
/**
* to get chatroom
* example data for method : $bot->getChatRoom()
*
* {
* "id": 1510,
* "qiscus_room_name": "Name of Chat Room",
* "qiscus_room_id": 8777,
* "is_group_chat": false,
* "created_at": "2017-06-02T01:33:12.233Z",
* "updated_at": "2017-06-02T01:33:12.233Z",
* "application_id": 3,
* "group_avatar_url": "",
* "is_official_chat": false,
* "target_user_id": 443,
* "is_public_chat": false,
* "is_channel": false,
* "users": [
* {
* "id": 287,
* "phone_number": "+6285123123123",
* "fullname": "Jarjit Singh",
* "qiscus_email": "[email protected]",
* "qiscus_id": 784
* },
* {
* "id": 22,
* "phone_number": "+628681234567",
* "fullname": "Cuti Bot",
* "qiscus_email": "[email protected]",
* "qiscus_id": 2039
* }
* ],
* "chat_name": "Group Chat Name",
* "chat_avatar_url": ""
* }
*/
$message = $bot->getMessage();
/**
* to get the message
* example data for method : $bot->getMessage()
*
* {
* "payload": {},
* "text": "halo bro",
* "type": "text"
* }
*/
$response = $bot->sendText($room['qiscus_room_id'], 'Hello, this is from Kiwari Bot SDK PHP');
var_dump($response); //you can see the response if you need to debug or something to handle in your bot
$path = '/Users/andhikayuana/Downloads/wav_wav_wavv.mp3';
$upload = $bot->upload($path);
var_dump($upload->body->data->url); // you can get the file url here
//now you can send the document like below
$response = $bot->sendDocument($room['qiscus_room_id'], $upload->body->data->url);
var_dump($response);