10

For instance to call/wrap the auth.sentCode method (link below):

https://core.telegram.org/method/auth.sendCode

I have tried:

var url = "https://149.154.167.40";  
var data = "(auth.sendCode \"PHONE_CODE+NO\" 0 APP_ID \"SECRET_HASH\" \"en\")";  
using (var wc = new WebClient())  
{  
var result = wc.UploadData(url, GetBytes(data));  
}  

I get this exception (and inner exception)

The underlying connection was closed: An unexpected error occurred on a send. (Authentication failed because the remote party has closed the transport stream.)

Christian Phillips
  • 18,399
  • 8
  • 53
  • 82
Mark Redman
  • 24,079
  • 20
  • 92
  • 147
  • I have no experience with this protocol, but most of the time I see exceptions like that it's an SSL/TLS issue. I see you're using a hard-coded IP - is it possible there's self-signed certificates that your app is rejecting? (Alternatively: does that endpoint definitely support https? I've gotten similar errors from sending https requests to an http endpoint.) – Chris Hayes May 19 '15 at 08:08
  • 1
    i think till now no example, just unimplemented lib's at githhub – Khalid Omar May 23 '15 at 11:54
  • I have posted some code (in vb.net) to get you started here http://stackoverflow.com/a/32809138/44080 – Charles Okwuagwu Sep 30 '15 at 18:03

3 Answers3

5

You an get started with this SO post

You would need to understand how to generate an AuthKey first.

The Telegram-API documentation is not very well written, but if you keep studying it... you eventually get the hand of it.

Working through generating the AuthKey would help you build up a pattern and functions that you can then use to tackle the rest of the API

Cheers.

Community
  • 1
  • 1
Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157
1

If you try to access to https://149.154.167.40 via a Web Browser, you can see that the https protocol is not enabled. If you look at here, there are a list of subdomains that implements https, you could try one of those to make your api request. I'm not really sure that telegram blocks your request due to the CROSS-ORIGIN policy, because the access-control-allow-origin:* header is present in the response. If that doesn't work, you could implement your own handshake like the android application does in here. I hope this help you.

1

Use TLSharp. To authenticate user, just run this code

   var hash = await client.SendCodeRequest(phoneNumber);

   var code = "1234"; //code that you receive from Telegram 

   var user = await client.MakeAuth(phoneNumber, hash, code); 
Ilia P
  • 616
  • 5
  • 16