Curl return TRUE if is there CURLOPT_RETURNTRANSFER, TRUE ? – php

  curl, php, php-telegram-bot, telegram, telegram-bot

Hi guys I’ll explain my code:

I have a telegram bot and I have to write many messages quickly in a group and to write a message it is necessary to execute a link (using the Telegram Api).

To do this I use Curl:

curl_setopt($ch, CURLOPT_URL, $url_telegram);
curl_setopt($ch, CURLOPT_HEADER, 0);    
curl_setopt($ch, CURLOPT_VERBOSE, 0);   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_USERAGENT, getRandomUserAgent());  
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
curl_setopt($ch, CURLOPT_TIMEOUT, 80);  


$return= curl_exec($ch);        
if($return !== FALSE){  //cURL works
   save_variable_in_js_file();
}

If the message is written I believe it must be:

$return == TRUE or maybe != False

So if is not false is run a function save_variable_in_js_file() that save a variable in a javascript file.
The strange thing is that some message are not written by bot, it seems not works and maybe its $return was == FALSE, but anyway the function is run and the variable saved in the file.

Why this ?
I know with CURLOPT_RETURNTRANSFER, TRUE $return‘s curl can be request or false.

Is this the problem ?

The method used with API Telegram to send message is sendMessage: https://core.telegram.org/method/messages.sendMessage

Source: Ask PHP

LEAVE A COMMENT