This file contains hidden or 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
| require('dotenv').config(); | |
| var request = require('request'); | |
| var querystring = require('querystring'); | |
| function getLuisIntent(utterance) { | |
| var endpoint = | |
| "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/"; | |
| // Set the LUIS_APP_ID environment variable |
This file contains hidden or 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
| ########### Python 3.6 ############# | |
| import requests | |
| headers = { | |
| # Request headers | |
| 'Ocp-Apim-Subscription-Key': '你的key', | |
| } | |
| params ={ | |
| # Query parameter |
This file contains hidden or 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
| //建立Bot instance | |
| isRock.LineBot.Bot bot = | |
| new isRock.LineBot.Bot(ChannelAccessToken); //傳入Channel access token | |
| //第一個Column | |
| var ImageCarouselColumn1 = new isRock.LineBot.ImageCarouselColumn | |
| { | |
| //設定圖片 | |
| imageUrl = new Uri("https://arock.blob.core.windows.net/blogdata201706/22-124357-ad3c87d6-b9cc-488a-8150-1c2fe642d237.png"), | |
| //設定回覆動作 |
This file contains hidden or 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
| namespace WebApplication5.Controllers | |
| { | |
| public class TestLUISController : isRock.LineBot.LineWebHookControllerBase | |
| { | |
| const string channelAccessToken = "~~~請改成自己的ChannelAccessToken~~~"; | |
| const string AdminUserId = "~~~改成你的AdminUserId~~~"; | |
| const string LuisAppId = "~~~改成你的LuisAppId~~~"; | |
| const string LuisAppKey = "~~~改成你的LuisAppKey~~~"; | |
| const string Luisdomain = "~~~改成你的Luisdomain~~~"; //ex.westus |
This file contains hidden or 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
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| //取得返回的code | |
| var code = Request.QueryString["code"]; | |
| if (code == null) | |
| { | |
| Response.Write("沒有正確回應code"); | |
| Response.End(); | |
| } | |
| //顯示,測試用 |
This file contains hidden or 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
| <html> | |
| <head> | |
| <title></title> | |
| <meta charset="utf-8" /> | |
| <script> | |
| function Auth() { | |
| var URL = 'https://access.line.me/oauth2/v2.1/authorize?'; | |
| URL += 'response_type=code'; | |
| URL += '&client_id=1554713403'; //請換成你自己的 client_id | |
| URL += '&redirect_uri=http://localhost:58155/Callback.aspx'; //請換成你自己的 callback url |
This file contains hidden or 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
| 序言 | |
| 讀者須知 | |
| 適合閱讀對象 | |
| 原始程式碼與範例 | |
| 閱讀說明 | |
| 更新紀錄 (改版更新均會同時在https://www.facebook.com/DotNetWalker 公告) | |
| 目錄 | |
| 第1章 建立你的第一隻Linebot | |
| 1-1 起手式 – 你的預備動作 | |
| 1-1-1 你需要的各種帳號 |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Net; | |
| using System.Net.Http; | |
| using System.Web.Http; | |
| namespace SimpleLineWebHook.Controllers | |
| { | |
| public class SimpleWebHookController : isRock.LineBot.LineWebHookControllerBase |
This file contains hidden or 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
| try | |
| { | |
| //取得 http Post RawData(should be JSON) | |
| string postData = Request.Content.ReadAsStringAsync().Result; | |
| //剖析JSON | |
| var ReceivedMessage = isRock.LineBot.Utility.Parsing(postData); | |
| var item = ReceivedMessage.events.FirstOrDefault(); | |
| string Message = ""; | |
| switch (item.type) |
This file contains hidden or 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 ExceptionNotify : PolicyInjectionAttributeBase | |
| { | |
| //指定Log File Name | |
| public string LogFileName { get; set; } | |
| //override OnException方法 | |
| public override void OnException(object sender, PolicyInjectionAttributeEventArgs e) | |
| { | |
| var msg = $"\r\n exception({DateTime.Now.ToString()}) : \r\n{e.Exception.Message }"; | |
| //Console.Write(msg); | |
| SaveLog(msg); |