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
| //將area加入RichMenuItem | |
| item.areas.Add(leftButton); | |
| item.areas.Add(rightButton); | |
| //建立Menu Item並綁定指定的圖片 | |
| var menu = isRock.LineBot.Utility.CreateRichMenu( | |
| item, new Uri("http://arock.blob.core.windows.net/blogdata201902/test01.png"), channelAccessToken); | |
| //將Menu Item設為預設Menu | |
| isRock.LineBot.Utility.SetDefaultRichMenu(menu.richMenuId, channelAccessToken); | |
| Response.Write($"OK, {menu.richMenuId}"); |
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
| //建立左方按鈕區塊 | |
| var leftButton = new isRock.LineBot.RichMenu.Area(); | |
| leftButton.bounds.x = 0; | |
| leftButton.bounds.y = 0; | |
| leftButton.bounds.width = 460; | |
| leftButton.bounds.height = 1686; | |
| leftButton.action = new MessageAction() { label = "左", text = "/左" }; |
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 Button1_Click(object sender, EventArgs e) | |
| { | |
| //建立RuchMenu | |
| var item = new isRock.LineBot.RichMenu.RichMenuItem(); | |
| item.name = "no name"; | |
| item.chatBarText = "快捷選單"; | |
| //建立左方按鈕區塊 | |
| var leftButton = new isRock.LineBot.RichMenu.Area(); | |
| leftButton.bounds.x = 0; | |
| leftButton.bounds.y = 0; |
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
| //如果是 '/add'開頭 | |
| if (msg.ToLower().StartsWith("/add")) //表單新增 | |
| { | |
| //以 '/' 分割收到的字串 | |
| var words = msg.Split('/'); | |
| try | |
| { | |
| //嘗試抓取每一個欄位 | |
| float num = float.Parse(words[2]); | |
| string datetime = words[5]; |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title></title> | |
| <script src="https://d.line-scdn.net/liff/1.0/sdk.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> | |
| <script> |
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
| var result = MSTranslatorUtility.Translate(this.textBox1.Text, "en"); //zh-Hant 為翻譯成中文 | |
| this.textBox2.Text = $"目標語系 : { result.FirstOrDefault().translations.FirstOrDefault().to}"; | |
| this.textBox2.Text += $"\r\n翻譯結果 : { result.FirstOrDefault().translations.FirstOrDefault().text}"; |
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 static List<MSTranslatorTextTranslateResult> Translate(string text, string LanguageCode) | |
| { | |
| // Translate to German and Italian. | |
| string path = "/translate?api-version=3.0"; //翻譯 | |
| string params_ = "&to=" + LanguageCode; //目標語系 | |
| string uri = MSTranslatorTextHost + path + params_; | |
| System.Object[] body = new System.Object[] { new { Text = text } }; | |
| var requestBody = JsonConvert.SerializeObject(body); |
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 static List<MSTranslatorTextDetectResult> Detect(string text) | |
| { | |
| string path = "/detect?api-version=3.0"; //偵測語系 | |
| string uri = MSTranslatorTextHost + path; | |
| System.Object[] body = new System.Object[] { new { Text = text } }; | |
| var requestBody = JsonConvert.SerializeObject(body); | |
| using (var client = new HttpClient()) | |
| using (var request = new HttpRequestMessage()) | |
| { |
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
| private void button1_Click(object sender, EventArgs e) | |
| { | |
| var result = MSTranslatorUtility.Detect(this.textBox1.Text); | |
| this.textBox2.Text = $"最有可能的語系是 : {result.FirstOrDefault().language}"; | |
| this.textBox2.Text += $"\r\n分數 : {result.FirstOrDefault().score}"; | |
| } |
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
| const string token = ""; //換成你的token | |
| const string AdminUserId = ""; //換成你的UserId | |
| //發送貼圖鈕 | |
| private void button2_Click(object sender, EventArgs e) | |
| { | |
| isRock.LineBot.Bot bot = new isRock.LineBot.Bot(token); | |
| //發送貼圖 | |
| bot.PushMessage(AdminUserId, 1,2); | |
| } |