简体   繁体   English

当我在 PHP 中使用 cURL 得到错误“连接后来自代理的 HTTP 403”时,我该怎么办?

[英]What should I do when I get error "HTTP 403 from proxy after CONNECT" using cURL in PHP?

I'd like to see my messages using Telegram API, like "/getupdates or "/getme", and I read I have to user cURL, but unfortunately I don't see anything on the page... blank page. So what's wrong whit my code blow here?我想使用 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;

?>

The error is: "url error: Received HTTP code 403 from proxy after CONNECT"错误是:“url 错误:CONNECT 后从代理收到 HTTP 代码 403”

You should get a number of warnings if the error reporting is enabled.如果启用了错误报告,您应该会收到许多警告。

For example, this one:例如,这个:

Warning: curl_setopt() expects exactly 3 parameters, 2 given in ..\index.php on line X

for this line specifically:专门针对这一行:

<?php
error_reporting(E_ALL);
ini_set("display_errors",1);
...
curl_setopt($ch, CURLOPT_RETURNTRANSFER);

In addition, where $handle comes from?另外, $handle是从哪里来的? it should be $ch , no?它应该是$ch ,不是吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP ZC1BEF293167E5FE84BD35C7D87D87D87D87D87D87D3E9D3E9D3E9D3E9D3E9D3E9D3E9D3E92C5E056C56C500A1C4B6A71110B50B50BENCTRENCTING cONTING tim sorr Z.110BADE92212222222222226FFFER Z.56FFFER Z.56FFFER Z. - PHP cURL request fails on https call with errno 56: “Received HTTP code 403 from proxy after CONNECT” 我应该怎么做才能获取cURL中的所有http链接 - what should i do for get all http links in cURL PHP cURL 在 CONNECT 后从代理收到 HTTP 代码 407 - PHP cURL Received HTTP code 407 from proxy after CONNECT PHP - 尝试与代理连接时出现 CURL 错误 - PHP - CURL error when trying to connect with proxy 使用php curl的HTTP错误403 - HTTP Error 403 with php curl Twilio&#39;在CONNECT之后从代理接收到HTTP代码403&#39; - Twilio 'Received HTTP code 403 from proxy after CONNECT' 56 CONNECT之后从代理收到HTTP代码403? - 56 Received HTTP code 403 from proxy after CONNECT? 尝试使用 php 发送 POST 请求,无论我做什么,我都会收到“HTTP ERROR 500” - Trying to send a POST request using php, No matter what i do i get "HTTP ERROR 500" 当我应该使用php curl获得状态304时获得HTTP状态200 - Getting HTTP status 200 when I should be getting status 304 using php curl 我的HTTP请求与cURL一起使用,但与wp_remote_get()一起使用,我收到错误403(禁止访问) - My HTTP request works with cURL but with wp_remote_get() I get error 403 (Forbidden)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM