Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaximStrutinskiy/5960babedb43e44a93b0a7c2a9171eba to your computer and use it in GitHub Desktop.
Save MaximStrutinskiy/5960babedb43e44a93b0a7c2a9171eba to your computer and use it in GitHub Desktop.
Telegram response
<?php
$site = "https://api.telegram.org/bot".$token;
$params = [
'chat_id' => '@'.$chanelId,
'text' => $text,
'parse_mode' => $parse_mode,
];
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120,
CURLOPT_POSTFIELDS => $params, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks
);
$ch = curl_init( $site.'/sendMessage' );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
echo '<pre>';
print_r($header);
echo '</pre>';
die();
?>
Response on server (app no working)
Array
(
[url] => https://api.telegram.org/bot612781475:AAFPt_jJkfux02twQtnLOzWmEklU6VHs0HE/sendMessage
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.221272
[namelookup_time] => 0.028652
[connect_time] => 0.06342
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 149.154.167.220
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => 172.17.0.72
[local_port] => 34130
[errno] => 35
[errmsg] => TCP connection reset by peer
[content] =>
)
Response on local machine (work)
-//-
[errno] => 0
[errmsg] =>
[content] => {"ok":true,"result":{"message_id":76,"chat":{"id":-1001305077429,"title":"#######","username":"#######","type":"channel"},"date":1529406800,"text":"qwe\n\nqwe\n\n\u0427\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435","entities":[{"offset":0,"length":3,"type":"bold"},{"offset":10,"length":15,"type":"text_link","url":"h ttps://########.ru/post/42 7"}]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment