I'm using Google Developers Console to build a bot for telegram.
everything works fine, except that when I try to send files (photo, audio, etc ..) php returns a fatal error for the lack of libraries Curl.
I checked and this is the php version 5.5.26, and also supports the new function CURLFile.
How can I fix?
I leave you the error that returns the console
1 - Method
function sendIMG($api_url,$path,$chatID)
{
$url = $api_url."sendPhoto?chat_id=".$chatID ;
$post_fields = array(
'chat_id' => $chatID,
'photo' => new \CURLFile(realpath($path))
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data"));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
$output = curl_exec($ch);
sendText($api_url, $chatID, $output);
}
PHP Fatal error: Class 'CURLFile' not found in /base/data/home/apps/s~macabreobot/1.389444928540417808/main.php on line 18
2 Method
function sendIMG_2($api_url,$path,$chatID)
{
$api_url = "https://api.telegram.org/botYOUR_BOT_TOKEN/";
$url = $api_url."sendPhoto?chat_id=".$chatID;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data"));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("photo" => "@".$path));
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($path));
$output = curl_exec($ch);
sendText($api_url, $chatID, $output);
}
PHP Fatal error: Call to undefined function curl_init() in /base/data/home/apps/s~macabreobot/1.389445039709239473/main.php on line 36