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 :
any advice and answers will really help me. thanks a lot.
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