iT邦幫忙

0

line notify 是否可以發flex messagese格式???

line notify 是否可以透過 API方式 發flex messagese格式???
比如下圖 圈選的flex messagese
https://ithelp.ithome.com.tw/upload/images/20210610/20013294h9h3rexWR7.png

我有嚐試 用flex 格式發送.不過都失敗!!!

底下是我的php程式碼




	//curl -i -X POST https://notify-api.line.me/api/notify -H "Authorization: Bearer <TOKEN>" -F "message=test" -F "imageFile=@C:\PATH\to\file.jpg"
	//https://developers.line.biz/media/messaging-api/messages/sticker_list.pdf
	 
	//Line Notify傳送訊息 
	//表頭
	$headers = array(
		'Content-Type: application/x-www-form-urlencoded',
		'Authorization: Bearer ' . $mem_linenotify
	);
	//要推播的訊息
	$message="";
	$message=$message. "\r\n\r\n" . $msg . "\r\n\r\n";
	//$message=$message. "新訂單\r\n\r\n";
	//$message=$message. "付款方式採用LinePay,請完成付款動作" . "\r\n";	
	$message=$message. "現在時刻: " . date('Y-m-d H:i:s');
	$Push_Content['message'] = $message;
	//$Push_Content['imageThumbnail'] = "https://i.imgur.com/ZxuJGHG.png"; //美女照片
	//$Push_Content['imageFullsize'] = "https://i.imgur.com/ZxuJGHG.png";	//美女照片
	//$Push_Content['stickerPackageId'] = "1";
	//$Push_Content['stickerId'] = "114";
	
/* $message='	{
  "type": "flex",
  "altText": "this is a flex message",
  "contents": {
    "type": "bubble",
    "body": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "text",
          "text": "hello"
        },
        {
          "type": "text",
          "text": "world"
        }
      ]
    }
  }
}'; */
	

	// 创建一个新cURL资源
	//$line_url=line_notify-apiUrl ."notify";
	$ch = curl_init();			//curl_setopt — 設置一個cURL傳輸選項。

	curl_setopt($ch, CURLOPT_URL , line_notify_apiUrl );	//需要获取的URL地址
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);		//一个用来设置HTTP头字段的数组

	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
	curl_setopt($ch, CURLOPT_POST, true);				//启用时会发送一个常规的POST请求
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($Push_Content));
	
	//curl_setopt($ch, CURLOPT_POSTFIELDS, $message);		//全部数据使用HTTP协议中的"POST"操作来发送。要发送文件
	curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1); // 不直接出現回傳值


	// 抓取URL并把它传递给浏览器
	$result = curl_exec($ch);
	$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

	//关闭cURL资源,并且释放系统资源
	curl_close($ch);

	writelog("result==>".$result);
	$obj=json_decode($result);
	if ($httpCode!=200){
		
		//$message=$obj->{"message"};

		return False;
		
	}

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
Han
iT邦研究生 1 級 ‧ 2021-06-10 21:02:34

否,可參考官方文件

目前只支援 貼圖、文字、圖片

感謝大大的回覆!!

因為感覺文字 太醜了...所以希望能有FLEX格式 訊息
謝謝...我知道方向了...

我要發表回答

立即登入回答