Skip to content

Instantly share code, notes, and snippets.

View isdaviddong's full-sized avatar

David Tung isdaviddong

View GitHub Profile
@isdaviddong
isdaviddong / app.js
Last active June 11, 2018 16:11
call LUIS by Node.js
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
@isdaviddong
isdaviddong / luis.py
Created June 9, 2018 03:45
call Luis API with Python
########### Python 3.6 #############
import requests
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '你的key',
}
params ={
# Query parameter
@isdaviddong
isdaviddong / default.aspx.cs
Created March 4, 2018 05:34
ImageCarouselColumn code snippet
//建立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"),
//設定回覆動作
@isdaviddong
isdaviddong / TestLUISController.cs
Created February 13, 2018 15:28
TestLUISController.cs
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
@isdaviddong
isdaviddong / callback.aspx.cs
Last active December 30, 2017 07:49
callback.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
//取得返回的code
var code = Request.QueryString["code"];
if (code == null)
{
Response.Write("沒有正確回應code");
Response.End();
}
//顯示,測試用
@isdaviddong
isdaviddong / index.html
Last active December 30, 2017 06:54
index.html
<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
@isdaviddong
isdaviddong / chapter.txt
Last active December 28, 2017 01:41
Line Bot 對談機器人 & 人工智慧辨識 開發實戰 - 章節
序言
讀者須知
適合閱讀對象
原始程式碼與範例
閱讀說明
更新紀錄 (改版更新均會同時在https://www.facebook.com/DotNetWalker 公告)
目錄
第1章 建立你的第一隻Linebot
1-1 起手式 – 你的預備動作
1-1-1 你需要的各種帳號
@isdaviddong
isdaviddong / SimpleWebHookController.cs
Last active January 7, 2018 04:28
SimpleWebHookController.cs
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
@isdaviddong
isdaviddong / LineBotGroupController.cs
Last active June 17, 2021 09:48
Line bot 群組對談範例程式碼
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)
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);