当我拨打此链接时 https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20151201T195234Z.a35326958c23a7a8.51da9f9c1ffe2d901f1ee0e4bf3cfdadfe19b3f8&ui=ru&text=apple&lang=en-ru在我的浏览器上可以正常工作,但是当我使用改装调用它时它给了我403 Forbidden。只有当我在改装中不使用钥匙时才能得到。当我使用密钥时,我没有通过调试得到回调。请帮助,我第二周痛苦
我使用retorfit所以: API
public interface APIService {
@GET("translate")
Call<Repo> loadRepo(
@Query(value = "key", encoded = true) String key ,
@Query("ui") String ui,
@Query("text") String text,
@Query("lang") String lang1) };
Repo r;
String text="apple"; String ui="ru";
String key="trnsl.1.1.20151201T195234Z.a35326958c23a7a8.51da9f9c1ffe2d901f1ee0e4bf3cfdadfe19b3f8";
String lang1="en-ru";
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://translate.yandex.net/api/v1.5/tr.json/")
.addConverterFactory(GsonConverterFactory.create())
// .client(httpClient)
.build();
service = retrofit.create(APIService.class);
service.loadRepo( URLEncoder.encode(key), ui, text, lang1).enqueue(new Callback<Repo>() {
@Override
public void onResponse(Response<Repo> response, Retrofit retrofit) {
r = response.body();
int a = 1; // under debug here I look response and see 403 Forbidden
}
@Override
public void onFailure(Throwable t) {
}
});