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 :
- why my code work successfully on GET event but not on POST event?
- 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.