Php 如何将图像本地发送到line notify?
我不确定line notify是否支持从本地发送图像 但我试着阅读文件,并尝试了许多图片 我还是不行。Php 如何将图像本地发送到line notify?,php,jquery,line,Php,Jquery,Line,我不确定line notify是否支持从本地发送图像 但我试着阅读文件,并尝试了许多图片 我还是不行。 如何向我发送照片文件 我尝试使用参数imageFile,但不起作用 /*-------------line noti----------------------*/ $line_api = 'https://notify-api.line.me/api/notify'; $access_token = 'token_code'; $message = 'test';
如何向我发送照片文件 我尝试使用参数
imageFile
,但不起作用
/*-------------line noti----------------------*/
$line_api = 'https://notify-api.line.me/api/notify';
$access_token = 'token_code';
$message = 'test'; //text max 1,000 charecter
$image_thumbnail_url = 'https://dummyimage.com/1024x1024/f598f5/fff.jpg'; // max size 240x240px JPEG
$image_fullsize_url = 'https://dummyimage.com/1024x1024/844334/fff.jpg'; //max size 1024x1024px JPEG
$imageFile = 'copy/240.jpg';
$sticker_package_id = ''; // Package ID sticker
$sticker_id = ''; // ID sticker
$message_data = array(
'imageThumbnail' => $image_thumbnail_url,
'imageFullsize' => $image_fullsize_url,
'message' => $message,
'imageFile' => $imageFile,
'stickerPackageId' => $sticker_package_id,
'stickerId' => $sticker_id
);
$result = send_notify_message($line_api, $access_token, $message_data);
echo '<pre>';
print_r($result);
echo '</pre>';
}
/*-------------line noti----------------------*/
function send_notify_message($line_api, $access_token, $message_data){
$headers = array('Method: POST', 'Content-type: multipart/form-data', 'Authorization: Bearer '.$access_token );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $line_api);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
// Check Error
if(curl_error($ch))
{
$return_array = array( 'status' => '000: send fail', 'message' => curl_error($ch) );
}
else
{
$return_array = json_decode($result, true);
}
curl_close($ch);
return $return_array;
}
/*------行noti----------------------*/
$line_api='2〕https://notify-api.line.me/api/notify';
$access_token='token_code';
$message='test'//文本最大1000字符
$image\u缩略图\u url='0https://dummyimage.com/1024x1024/f598f5/fff.jpg'; // 最大尺寸240x240px JPEG
$image\u fullsize\u url='1https://dummyimage.com/1024x1024/844334/fff.jpg'; //最大尺寸1024x1024px JPEG
$imageFile='copy/240.jpg';
$sticker\u package\u id='''.//包裹识别标签
$sticker_id=“”;//身份证贴纸
$message\u data=数组(
“imageThumbnail”=>$image\u thumbnail\u url,
“imageFullsize”=>$image\u fullsize\u url,
'message'=>$message,
“imageFile”=>$imageFile,
“贴纸包装id”=>$贴纸包装id,
'stickerId'=>$sticker\u id
);
$result=send\u notify\u message($line\u api、$access\u token、$message\u data);
回声';
打印(结果);
回声';
}
/*-------------诺蒂线----------------------*/
函数send\u notify\u message($line\u api、$access\u token、$message\u data){
$headers=array('Method:POST','Content type:multipart/formdata','Authorization:Bearer'.$access\u token);
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$line_api);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$message_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result=curl\u exec($ch);
//检查错误
if(旋度误差($ch))
{
$return_array=array('status'=>'000:send fail','message'=>curl_error($ch));
}
其他的
{
$return\u array=json\u decode($result,true);
}
卷曲关闭($ch);
return$return\u数组;
}
否imageFile
:
如何将图像本地发送到行通知?
请考虑添加解释。$imageFile = new CURLFILE('copy/240.jpg');
$imageFile = new CURLFILE('copy/240.jpg');
$file_name_with_full_path = 'D:\\xampp\htdocs\linenotify\images\flower.jpg';
$imageFile = curl_file_create($file_name_with_full_path);