Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 发送消息的控制台_C#_Telegram - Fatal编程技术网

C# 发送消息的控制台

C# 发送消息的控制台,c#,telegram,C#,Telegram,我正在尝试使用TLsharp库通过一个简单的C#控制台应用程序发送电报。我的程序运行,但我没有收到消息。我已经完成了在电报网站上创建应用程序的过程,并收到了必要的哈希id和代码。请协助 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using TeleSharp.TL; using TLSharp; using

我正在尝试使用TLsharp库通过一个简单的C#控制台应用程序发送电报。我的程序运行,但我没有收到消息。我已经完成了在电报网站上创建应用程序的过程,并收到了必要的哈希id和代码。请协助

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeleSharp.TL;
using TLSharp;
using TLSharp.Core;

   namespace TLsharpTest
    {
       class Program
      {

    const int apiId = 55xxx;
    const int groupId = -167xxxxx;
    const string apiHash = "220xxxxxxxx";
    const string number = "27xxxxxxx";
    static void Main(string[] args)
    {

        var client = new TelegramClient(apiId, apiHash);
        client.ConnectAsync();


        var hash = client.SendCodeRequestAsync(number);
        var code = "55xxx"; // you can change code in debugger
        var user = client.MakeAuthAsync(number, apiHash, code);
        client.SendMessageAsync(new TLInputPeerUser() { user_id = groupId },             "TEST");
        Console.ReadKey();
    }


  }
}

您应该拥有用户的访问权限以发送消息。应该是这样的:

 _client.SendMessageAsync(
                new TLInputPeerUser()
                {
                    user_id = channelUser.Id,
                    access_hash = channelUser.AccessHash
                }