调用电报 API 方法的正确方法
我正在我的java应用程序中研究Telegram api。我需要使用我的电报帐户进行身份验证和授权,并获取我的特定组的消息列表。为此,我首先从电报站点获得。其次,我试图以这种方式用方法授权我的帐户:api_id
api_hash
MTProto servers
auth.sendCode
...
String url = "https://149.154.167.40:443/auth.sendCode";
HttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-type", "application/x-www-form-urlencoded");
httpPost.addHeader("charset", "UTF-8");
List<NameValuePair> nameValuePairs = new ArrayList<>();
nameValuePairs.add(new BasicNameValuePair("phone_number", myPhoneNumber));
nameValuePairs.add(new BasicNameValuePair("sms_type", "5"));
nameValuePairs.add(new BasicNameValuePair("api_id", api_id));
nameValuePairs.add(new BasicNameValuePair("api_hash", api_hash));
nameValuePairs.add(new BasicNameValuePair("lang_code", "en"));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
HttpResponse response = httpClient.execute(httpPost);
...
但这又让我例外。我测试了网址而不是,这返回了html内容。在java中调用电报API方法的正确方法是什么?javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
http
https
404 Not Found
更新:
我尝试使用发送TCP发布请求,但这会返回我。java socket
404 not found