通过 Telegram API 客户端发送位置
Send Location by Telegram API client
我使用 TLSharp 库。我怎样才能将我的位置发送给用户。我知道如何发送简单的短信,但不明白如何分享我的地理位置。
var store = new FileSessionStore();
var client = new TelegramClient(api_id, api_hash, store,"session");
await client.ConnectAsync();
...
await client.SendMessageAsync(new TLInputPeerUser() { UserId = userByPhoneId.Id }, "Simple mess");
我创建请求:
TLInputPeerUser ip = new TLInputPeerUser() { UserId = user.Id };
TLInputMediaGeoPoint igp = new TLInputMediaGeoPoint();
igp.GeoPoint = new TLInputGeoPoint() { Lat= ..., Long= ...};
var req = new TLRequestSendMedia()
{
Media = igp ,
Peer = ip,
RandomId =
};
await client.SendRequestAsync<Boolean>(req);
但这不起作用,因为需要值 RandomId。 Random Id 有 long 类型,我尝试生成随机 long 数字但它没有帮助,我收到错误。
var req = new TLRequestSendMedia()
{
Media = igp,
Peer = ip,
RandomId = Helpers.GenerateRandomLong()
};
await client.SendRequestAsync<TLAbsUpdates>(req);
我使用 TLSharp 库。我怎样才能将我的位置发送给用户。我知道如何发送简单的短信,但不明白如何分享我的地理位置。
var store = new FileSessionStore();
var client = new TelegramClient(api_id, api_hash, store,"session");
await client.ConnectAsync();
...
await client.SendMessageAsync(new TLInputPeerUser() { UserId = userByPhoneId.Id }, "Simple mess");
我创建请求:
TLInputPeerUser ip = new TLInputPeerUser() { UserId = user.Id };
TLInputMediaGeoPoint igp = new TLInputMediaGeoPoint();
igp.GeoPoint = new TLInputGeoPoint() { Lat= ..., Long= ...};
var req = new TLRequestSendMedia()
{
Media = igp ,
Peer = ip,
RandomId =
};
await client.SendRequestAsync<Boolean>(req);
但这不起作用,因为需要值 RandomId。 Random Id 有 long 类型,我尝试生成随机 long 数字但它没有帮助,我收到错误。
var req = new TLRequestSendMedia()
{
Media = igp,
Peer = ip,
RandomId = Helpers.GenerateRandomLong()
};
await client.SendRequestAsync<TLAbsUpdates>(req);