LINE Notify Hands-on lab === ##### 背景與用途: 企業、商家可大量發送訊給用戶,無需申請LINE Bot ##### Hands-on lab 1.前往 https://notify-bot.line.me/zh_TW/ 建立LINE Notify服務  2.建立好後,取得 Clien ID, Client Secret  3.設定 CallbackURL(此URL依照你的專案而定,可先隨意設定,正確資訊請參考底下步驟四的程式碼與port設定)  4.Download example Project https://github.com/isdaviddong/Line_Notify_Example/tree/master/Line_Notify_Example  5.使用Visual Studio開啟專案後, 先rebuild 6.開啟default.aspx,修改client_id為先前步驟2取得的資訊, 並將redirect_url(範例中是http://localhost:3696/Callback.aspx)更新到你的line notify後台callback url設定(步驟3) ```htmlmixed= (...略...) //建立OAuth 身分驗證頁面並導入 function Auth() { var URL = 'https://notify-bot.line.me/oauth/authorize?'; URL += 'response_type=code'; URL += '&client_id=???'; //TODO:這邊要換成你的client_id URL += '&redirect_uri=http://localhost:3696/Callback.aspx'; //TODO:要將此redirect url 填回你的 LineNotify後台設定 URL += '&scope=notify'; URL += '&state=abcde'; window.location.href = URL; } (...略...) ``` :::info 上述的redirect_url原則上應該是http://localhost:3696/Callback.aspx 除非port與你local的環境有衝突。 ::: 7.以步驟2取得的Clien ID, Client Secret修改Callback.aspx.cs ```csharp (...略...) //顯示,測試用 Response.Write("<br/> code : " + code); //從Code取回toke var token = Utility.GetToeknFromCode(code, "???", //TODO:請更正為你自己的 client_id "???", //TODO:請更正為你自己的 client_secret "http://localhost:3696/Callback.aspx"); //顯示,測試用 Response.Write("<br/> token : " + token.access_token); (...略...) ``` 8.在Visual Studio中以F5執行App,嘗試取得Token  9.以該Token發送Notify訊息 參考資料 === Line Notify 概念請參考 http://studyhost.blogspot.tw/2016/12/linebot6-botline-notify.html Github example https://github.com/isdaviddong/Line_Notify_Example 相關資源 === LineBotSDK:https://www.nuget.org/packages/LineBotSDK 相關課程:http://www.studyhost.tw/NewCourses/LineBot 線上課程:https://www.udemy.com/line-bot/ 更多內容,請參考電子書:https://www.pubu.com.tw/ebook/103305 LINE Bot實體書籍:https://www.tenlong.com.tw/products/9789865020354
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up