V
V
Vyzhym2018-01-03 12:52:36
PHP
Vyzhym, 2018-01-03 12:52:36

How to send a keyboard in Viber?

How to send keyboard from php to viber?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AleksMo, 2019-04-05
@Vyzhym

<?php
//$receiverID is who to send the keyboard to...
# Examples: https://viber.github.io/docs/tools/keyboard-examples/
function send_klava($receiverID){
$curl = curl_init();
$json_data = '{
"receiver":"'.$receiverID.'",
"type":"text",
"text":"Hello world",
"keyboard":{
"Type":"keyboard",
"DefaultHeight ":false,
"Buttons":[
{
"ActionType":"reply",
"ActionBody":"reply to me",
"Text":"
$data = json_decode($json_data); // Convert code to json
curl_setopt_array($curl, array(
CURLOPT_URL => " https://chatapi.viber.com/pa/send_message ",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT = > 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($data) , // send code
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/ JSON",
"X-Viber-Auth-Token: 0000c419ece7d075-4c64680ae0e809a8-ab8000624a14e0000"
),
));
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
}
//Sending the keyboard to the user with id
send_klava('yI8UmH+jb9ZAzyYtU/mYwg==');
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question