我试图使用cURL将照片发送到Telegram bot API,但当我在chat_id字段中使用"@"时,我会收到以下错误:Deprecated: curl_setopt_array(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class
这是我的代码:
$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);
如何告诉cURL这个@不是文件名。
谢谢!
根据php手册:
通过将CURLOPT_safe_UPLOAD选项设置为TRUE,可以禁用@前缀以安全传递以@开头的值。