Created
December 11, 2016 05:19
-
-
Save isdaviddong/b339c5d8cf5ee4304f1134758e3ae7f5 to your computer and use it in GitHub Desktop.
Line Bot WebHook 範例
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
public class LineChatController : ApiController | |
{ | |
[HttpPost] | |
public IHttpActionResult POST() | |
{ | |
string ChannelAccessToken = "DETqsnH04xR7Xv...(請輸入你自己的ChannelAccessToken)...1cDnyilFU="; | |
try | |
{ | |
//取得 http Post RawData(should be JSON) | |
string postData = Request.Content.ReadAsStringAsync().Result; | |
//剖析JSON | |
var ReceivedMessage = isRock.LineBot.Utility.Parsing(postData); | |
//回覆訊息 | |
string Message; | |
Message = "你說了:" + ReceivedMessage.events[0].message.text; | |
//回覆用戶 | |
isRock.LineBot.Utility.ReplyMessage(ReceivedMessage.events[0].replyToken, Message, ChannelAccessToken); | |
//回覆API OK | |
return Ok(); | |
} | |
catch (Exception ex) | |
{ | |
return Ok(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment