doucheng5209 2016-08-19 02:56
浏览 21

关于事件后的LINE BOT API内部错误(500)但是在get事件上成功

I did many curl format to send message using LINE BOT API, but always get 500 error.

Here is my last post curl code

$apiCall = 'https://trialbot-api.line.me/v1/events';

$params = array();
$params['to'] = ["uf92dfc2702b46be071376c8ff81a4b56"];
$params['toChannel'] = 1383378250;
$params['eventType'] = "138311608800106203";
$params['content'] = [ "contentType" => 1,
                       "toType" => 1,
                       "text" => "the text"];
$string_data = json_encode($params)

$headers = array (
            "Content-Type: application / json; charset = UTF-8",
            "X-Line-ChannelID: 1476460XXX",
            "X-Line-ChannelSecret: 6363d24b1e356c77189137b6362XXXXX",
            "X-Line-Trusted-User-With-ACL: u54bf222a19fd3114e9eb1a3499dXXXXX"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiCall);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_POSTFIELDS, $string_data);
$jsonData = curl_exec($ch);
curl_close($ch);

$results = json_decode($jsonData,TRUE);

And here is the result

array:2 [
  "statusCode" => "500"
  "statusMessage" => "internal error."
]

And this is my get code (proccess successfully)

$url = "https://trialbot-api.line.me/v1/profiles?mids=uc02643a656b777f66162e121fa697f82";
$curl = curl_init ($url) ;
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
     'Content-Type: application/json; charset = UTF-8',
     'X-Line-ChannelID: 1476460XXX',
     'X-Line-ChannelSecret: 6363d24b1e356c77189137b6362XXXXX',
     'X-Line-Trusted-User-With-ACL: u54bf222a19fd3114e9eb1a3499dXXXXX')
);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec ($curl) ;
curl_close($curl);

The question are :

  1. why my code work successfully on GET event but not on POST event?
  2. is it true that error 500 is the error from the server (LINE server) ?

any advice and answers will really help me. thanks a lot.

  • 写回答

1条回答 默认 最新

  • doudou348131346 2016-08-26 04:37
    关注

    You can try this curl request send messages:

    curl -X POST \
    -H 'Content-Type: application/json; charset=UTF-8' \
    -H 'X-Line-ChannelID: 147XXXX741' \   //your channel ID
    -H 'X-Line-ChannelSecret: ff9051XXXXXXb5531e3eb633b24c2e73' \   //Your channel Secret
    -H 'X-Line-Trusted-User-With-ACL: uc866bXXXXXX8b4fbc3f4dd43befd66c9' \  //Your channel mid
    -d '{
       "to":["u004ddf56dXXXXXb2f9760e02f0a7b623"], //List of users MID
       "toChannel": 1383378250, //Fixed
       "eventType": "138311608800106203", //Fixed
       "content":{
           "contentType":1,
           "toType":1,
           "text":"hallo"
       }
    }' https://trialbot-api.line.me/v1/events
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大