0% found this document useful (0 votes)
116 views

API Telegram

The document introduces several methods for the Telegram bot API. It shows examples of using the getMe method to retrieve basic information about a bot and the sendMessage and forwardMessage methods to send and forward messages. Code samples in PHP are provided to demonstrate calling the API methods and processing the responses.

Uploaded by

Hossein
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views

API Telegram

The document introduces several methods for the Telegram bot API. It shows examples of using the getMe method to retrieve basic information about a bot and the sendMessage and forwardMessage methods to send and forward messages. Code samples in PHP are provided to demonstrate calling the API methods and processing the responses.

Uploaded by

Hossein
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

‫ ﻣﻌﺮﻓﯽ ﻣﺘﺪﻫﺎی‬Api ‫ﺭﺑﺎﺕ ﺗﻠﮕﺮﺍﻡ‬ http://alihossein.

ir/tutorials/‫ﻣﺘﺪﻫﺎی‬-‫ﻣﻌﺮﻓﯽ‬-api-‫ﺗﻠﮕﺮﺍﻡ‬-‫ﺭﺑﺎﺕ‬

https://api.telegram.org/bot136681112:AAGP_1qsss7muQTcQ54On8GfEwLdISrDRME/getMe

$url='https://api.telegram.org/bot136681112:AAGP_1qsss7muQTcQ54On8GfEwLdISrDRME/getMe';
die(file_get_contents($url));

{
"ok": true,
"result": {

1 of 5 11/25/2017, 9:25 PM
‫ ﻣﻌﺮﻓﯽ ﻣﺘﺪﻫﺎی‬Api ‫ﺭﺑﺎﺕ ﺗﻠﮕﺮﺍﻡ‬ http://alihossein.ir/tutorials/‫ﻣﺘﺪﻫﺎی‬-‫ﻣﻌﺮﻓﯽ‬-api-‫ﺗﻠﮕﺮﺍﻡ‬-‫ﺭﺑﺎﺕ‬

"id": 136682222,
"first_name": "‫"ﺭﺑﺎﺕ ﺗﺴﺖ‬,
"username": "alihossein_bot"
}
}

$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,"https://api.telegram.org/bot136681112:AAGP_1qsMs7muQTcQ54O99GfEwLdISr
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$json=curl_exec($curl);
$obj = json_decode($json);
die($obj->result->username) ;

<?php
$token='‫;'ﺗﻮﮐﻦ ﻣﻮﺭﺩ ﻧﻈﺮ ﺷﻤﺎ‬
$chatId='‫;'ﺁی ﺩی ﮐﺎﺭﺑﺮ ﻳﺎ ﮔﺮﻭﻩ ﻳﺎ ﮐﺎﻧﺎﻝ ﻣﻮﺭﺩ ﻧﻈﺮ‬
$text='‫;'ﻣﺘﻦ ﭘﻴﻐﺎﻡ ﻣﻮﺭﺩ ﻧﻈﺮ‬
$sendResponseUrl = 'https://api.telegram.org/bot'.$token . '/sendMessage?parse_mode=HTML&chat_id='.$chat

file_get_contents($sendResponseUrl);

<?php
$token='‫;'ﺗﻮﮐﻦ ﻣﻮﺭﺩ ﻧﻈﺮ ﺷﻤﺎ‬
$chatId='‫;'ﺁی ﺩی ﮐﺎﺭﺑﺮ ﻳﺎ ﮔﺮﻭﻩ ﻳﺎ ﮐﺎﻧﺎﻝ ﻣﻮﺭﺩ ﻧﻈﺮ‬
$text='‫;'ﻣﺘﻦ ﭘﻴﻐﺎﻡ ﻣﻮﺭﺩ ﻧﻈﺮ‬
$forwardResponseUrl = 'https://api.telegram.org/bot'.$token . '/forwardMessage?chat_id='.$chatId.'&from_

file_get_contents($forwardResponseUrl);

2 of 5 11/25/2017, 9:25 PM
‫ﺭﺑﺎﺕ ﺗﻠﮕﺮﺍﻡ ‪ Api‬ﻣﻌﺮﻓﯽ ﻣﺘﺪﻫﺎی‬ ‫ﺭﺑﺎﺕ‪-‬ﺗﻠﮕﺮﺍﻡ‪-api-‬ﻣﻌﺮﻓﯽ‪-‬ﻣﺘﺪﻫﺎی‪http://alihossein.ir/tutorials/‬‬

‫‪3 of 5‬‬ ‫‪11/25/2017, 9:25 PM‬‬


‫ﺭﺑﺎﺕ ﺗﻠﮕﺮﺍﻡ ‪ Api‬ﻣﻌﺮﻓﯽ ﻣﺘﺪﻫﺎی‬ ‫ﺭﺑﺎﺕ‪-‬ﺗﻠﮕﺮﺍﻡ‪-api-‬ﻣﻌﺮﻓﯽ‪-‬ﻣﺘﺪﻫﺎی‪http://alihossein.ir/tutorials/‬‬

‫‪4 of 5‬‬ ‫‪11/25/2017, 9:25 PM‬‬


‫ﺭﺑﺎﺕ ﺗﻠﮕﺮﺍﻡ ‪ Api‬ﻣﻌﺮﻓﯽ ﻣﺘﺪﻫﺎی‬ ‫ﺭﺑﺎﺕ‪-‬ﺗﻠﮕﺮﺍﻡ‪-api-‬ﻣﻌﺮﻓﯽ‪-‬ﻣﺘﺪﻫﺎی‪http://alihossein.ir/tutorials/‬‬

‫‪5 of 5‬‬ ‫‪11/25/2017, 9:25 PM‬‬

You might also like