我使用Google Developers Console爲電報構建了一個bot。在Google Developers Console中使用CURL php
一切工作正常,除了當我嘗試發送文件(照片,音頻等..)PHP返回一個致命的錯誤缺乏庫捲曲。
我檢查了這是php版本5.5.26,並且還支持新功能CURLFile。
我該如何解決?
我離開你,返回控制檯
1的錯誤 - 法
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的方法
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