2016-02-03 12 views
-1

我想看看我的消息使用電報API,如「/ getupdates或」/ getme「,我讀了我必須用戶捲曲,但不幸的是我沒有看到任何東西在頁面上...空白頁。 那麼,什麼是這裏錯了白衣我的代碼的打擊當我在PHP中使用cURL出現錯誤「來自代理連接後的HTTP 403的HTTP 403」時應該怎麼做?

<?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代理CONNECT後」

+0

'error_reporting(E_ALL)'在'<?php'之後的頁面的頂部。此外,如果有任何評估錯誤響應:'if(curl_errno($ ch)){echo'Curl error:'。 curl_error($ ch);}' – Ohgodwhy

+0

你的意思是「ini_set(」error_reporting「,E_ALL);」 ? – Donovant

+0

編號我的意思是[error_reporting](http://php.net/manual/en/function.error-reporting.php) – Ohgodwhy

回答

0

你應該得到一些警告,如果錯誤報告

例如,這個:

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,不是嗎?

+0

o.O?對不起,我沒有聽到你說的...我得到的錯誤是:「網址錯誤:從CONNECT後代理收到HTTP代碼403」 – Donovant