Last active
May 30, 2016 16:13
-
-
Save pankpan/936a94175b7ef720599a24d0b2c285d1 to your computer and use it in GitHub Desktop.
LINE BOT PHP Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$channel_id="xxxxxxxxxx"; | |
$channel_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
$channel_mid="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
$endpoint_url="https://trialbot-api.line.me/v1/events"; | |
$arr=json_decode(file_get_contents("php://input"),1); | |
$from=$arr['result'][0]['content']['from']; | |
$text=$arr['result'][0]['content']['text']; | |
$post_data="{\"to\":[\"$from\"],\"toChannel\":1383378250,\"eventType\":\"138311608800106203\",\"content\":{\"contentType\":1,\"toType\":1,\"text\":\"$text\"}}"; | |
$ch=curl_init(); | |
$headers=array("Content-Type: application/json; charser=UTF-8","X-Line-ChannelID: $channel_id","X-Line-ChannelSecret: $channel_secret","X-Line-Trusted-User-With-ACL: $channel_mid"); | |
curl_setopt($ch, CURLOPT_URL, $endpoint_url); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
curl_exec($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment