Senin, 06 April 2020

Telegram BOT


set webhook

https://api.telegram.org/bot{my_bot_token}/setWebhook?url={url_to_send_updates_to}

you should set code like this:

<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization');

$data = file_get_contents("php://input");
$data = json_decode($data,true);
$msg = (object) $data;
$f=print_r($msg,true);
print_r($msg);
file_put_contents("wh.txt",$f);
?>

<?php
session_start();
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
date_default_timezone_set('Asia/Jakarta');
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization');
//REQUIRED TO REPLY MESSAGE
header("Content-Type: application/json");
$data = file_get_contents("php://input");
$data = json_decode($data,true);
$msg = (object) $data[message];
$coming = (object) $data;

$f=print_r($coming,true);
file_put_contents("wh.txt",$f);

$chat_id = $msg->chat[id];

$text = $msg->text;
$text=str_replace("@intec_sipadebot","",$text);
$message=strtoupper($text);

$inlinekeyboard[] = ['text' => "Kirim Nomor"'url' => '', callback_data => "call_back_data"'request_contact' => true];
$inlinekeyboard[] = ['text' => "Kirim Lokasi"'url' => '', callback_data => "call_back_data"];

$keyboard = ['inline_keyboard' => [$inlinekeyboard], 'one_time_keyboard' => true,'resize_keyboard' => true];
$parameters = array('chat_id' => $chat_id, "text" => "Pilih apa yang anda bagikan");
$parameters["method"] = "sendMessage";
$parameters["reply_markup"] = json_encode($keyboard, true);
echo json_encode($parameters);
/*









Tidak ada komentar:

Posting Komentar

Foto Propades