'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?

<?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"



Solution 1:[1]

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? it should be $ch, no?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1