在asp.net web中使用Telegram api

编程入门 行业动态 更新时间:2024-10-25 03:32:16
本文介绍了在asp web中使用Telegram api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有创建约会的申请。我想通过电报从我的网站发送消息给一些固定用户(他们在手机上安装了电报。)。 i检查了这个链接:https://github/zhukov/webogram API:https://core.telegram/api 使用api的其他应用程序:https://telegram/apps 并创建了telegram的appconfiguration.but icanot找到一个合适的简单示例,显示如何在asp .plz中使用这个api帮助我做了一个搜索的厌烦。我发现在我的机器上工作的webogram但我找不到他们怎么称呼api。我是asp的初学者。我想知道如何从我的asp页面.plz帮助调用api。我之前被问过同样的问题,但没有人重播:(。 抱歉我的英语不好.PLZ帮助

i have an application for creating appointment. i want to send message via telegram from my website to some fixed users(they have telegram installed in their mobile phone. ). i checked this link: github/zhukov/webogram API : core.telegram/api Other applications using the api : telegram/apps and created appconfiguration for telegram.but icanot find a suitable simple example which shows how this api can be used in asp .plz help i have done a loat of search .i found webogram which worked in my machine too but i cant find out how they called api . i m a beginner in asp. i want to know how api call from my asp pages .plz help . i am asked same question before but no one replayed :(. sorry for my bad English . PLZ help

推荐答案

Hi 我写这段代码给我的联系人发送消息 首先你必须从nuget安装TLSharp - > Hi I write this code for sending message to my contacts first you must install TLSharp from nuget --> Install-Package TLSharp

public static async void GetMyContacts() { //get available contacts var client = new TelegramClient(ApiId, "ApiHash"); await client.ConnectAsync(); var hash = await client.SendCodeRequestAsync("+YourPhoneNumber"); var code = "32000"; // you can change code in debugger //code will send via telegram to you TLUser user = null; try { user = await client.MakeAuthAsync("+YourPhoneNumber", hash, code); } catch (CloudPasswordNeededException ex) { //if u activate two step verification in telegram var password = await client.GetPasswordSetting(); var password_str = "yourPassword"; user = await client.MakeAuthWithPasswordAsync(password, password_str); } if (client.IsUserAuthorized()) { //get available contacts var result = await client.GetContactsAsync(); //find recipient in contacts var userr = result.users.lists .Where(x => x.GetType() == typeof(TLUser)) .Cast<TLUser>() .FirstOrDefault(x => x.username == "a username from ur contacts in telegram"); //send message await client.SendMessageAsync(new TLInputPeerUser() { user_id = userr.id }, "My Message :Hi :)"); } }

更多推荐

在asp.net web中使用Telegram api

本文发布于:2023-11-11 06:27:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577628.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:net   asp   web   api   Telegram

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!