title: Correct way to call telegram api methods
body: <p>I'm working on Telegram api in my java application. <strong>I need to do authentication and authorization with my telegram account and get message list of my specific group.</strong> For this purpose, first I got <code>api_id</code>, <code>api_hash</code> and <code>MTProto servers</code> from telegram site. Second, I tried to authorize my account with <code>auth.sendCode</code> method in this way:</p>
  
  <pre><code>...
  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&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;&gt;();
  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);
  ...
  </code></pre>
  
  <p>But this returns me <code>javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake</code> exception. I tested url with <code>http</code> instead of <code>https</code> and this returned <code>404 Not Found</code> html content. <strong>What is the correct way for calling telegram api method in java?</strong></p>
  
  <p><strong>Update:</strong></p>
  
  <p>I tried using <code>java socket</code> for sending TCP post request, but this returns me <code>404 not found</code>.</p>