2017-06-22 6 views
3

現在、私は電信インタフェースを持つ単純なボットで作業しています。問題は、その要求は、httpリクエストを行う手段があるが、私はどのようにhttps要求をする手がかりがないということです。 は、私は、HTTPSが電報ボットAPIへのScalaライブラリfinagleと要求作ってみました: Finagle to Telegram APIを使用して適切なhttpsリクエストを作成する方法

val service: Service[http.Request, http.Response] = Http.client.withTlsWithoutValidation.newService("api.telegram.org:443") 
val request = http.Request(http.Method.Get,bottoken + "/getMe") 
request.host = "api.telegram.org" 
val t = Await.result(service(request) onSuccess(a => a) onFailure(exc => println("Auth check failed : " + exc.toString))) 
if (t.status == Status.Ok) { 
    println("Auth check success") 
} else { 
    println("Auth check failed : " + t.toString + "\r\n" + t.contentString) 
} 

私はそれが400不正な要求のHTTP応答を生成するこのコードを実行するたびに。

Http.client.withTls("api.telegram.org") 

も同じ結果をもたらす。 何が間違っていますか?

答えて

0

リクエストにhttpプロトコルを追加する必要があります。

val request = http.Request(http.Method.Get, "http://yourholeHost/getMe") 
関連する問題