我想用api方法用电报发送照片 我的php类是TelegramBotPHP
我的PHP代码
$img = curl_file_create('test.png','image/png');
$content = array('chat_id' => $chat_id, 'photo' => $img );
$telegram->sendPhoto($content);
返回错误
ok: False
curl_error_code: 26
curl_error: couldn't open file "test.png"
使用CURL上传文件的助手
if (!function_exists('curl_file_create')) {
function curl_file_create($filename, $mimetype = '', $postname = '')
{
return "@$filename;filename="
.($postname ?: basename($filename))
.($mimetype ? ";type=$mimetype" : '');
}
}