I'm trying to send photo to Telegram bot API using cURL but when I'm using "@" in chat_id field, I get this error:
Deprecated: curl_setopt_array(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class
Here is my code:
$post = array('chat_id' => '@ameer_test', 'photo'=> new CURLFile('E:\wamp\www\test/content/uploads/sample.png'));
$curl = curl_init("https://api.telegram.org/bot122877145:AAH-mTygl1FeisuOnsESbCVerRqd6-DTxD0/sendPhoto");
curl_setopt_array($curl, array(
//CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SAFE_UPLOAD => 0,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $post
));
$response = curl_exec($curl);
curl_close($curl);
var_dump($response);
How to tell cURL that this @ isn't filename.
Thank you!
According to php manual:
The @ prefix can be disabled for safe passing of values beginning with @ by setting the CURLOPT_SAFE_UPLOAD option to TRUE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.