skip to Main Content

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”

2

Answers


  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?

    Login or Signup to reply.
  2. in apache/conf/extra there will be file httpd_proxy.conf, set

    ProxyRequests On
    

    and below that add :

    AllowCONNECT port[-port] [port[-port]]
    

    For ex :

    ProxyRequests On
    AllowCONNECT 443 112 1002
    

    1002 is destination port, restart apache and try

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search