我想使用Telegram API查看我的消息,比如"/getupdates“或"/getme",我读到我必须使用cURL,但不幸的是我在页面上没有看到任何东西...空白页面。那么我的代码在这里出错了吗?
<?php
$botToken = "172894271:****myTelegramBotId****";
$botUrl = "https://api.telegram.org/bot" . $botToken;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $botUrl."/geupdates");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
//url error: Received HTTP code 403 from proxy after CONNECT
if(curl_errno($ch)) { echo 'Curl error: ' . curl_error($ch);}
echo $result;
?>错误是:"url错误:连接后从代理收到HTTP代码403“
发布于 2016-02-04 04:27:39
如果启用了错误报告,您应该会收到许多警告。
例如,这一条:
Warning: curl_setopt() expects exactly 3 parameters, 2 given in ..\index.php on line X特别是对于这一行:
<?php
error_reporting(E_ALL);
ini_set("display_errors",1);
...
curl_setopt($ch, CURLOPT_RETURNTRANSFER);此外,$handle从何而来?应该是$ch,不是吗?
https://stackoverflow.com/questions/35186716
复制相似问题