-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue that broke the ability to use an old-style Bing API Key
- Loading branch information
Showing
3 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi ,
I follow the example code and it works yesterday.But tody i found Translate.excute failed always.I found Translate.execute blocks alway.I sure that my network is ok.
My code is:
Translate.setClientId(CLIENT_ID);
Translate.setClientSecret(CLIENT_SECRET);
result = Translate.execute(target, LanguageHelper.getLanguageByName(context, fromLang), LanguageHelper.getLanguageByName(context, toLang));
I had update the newest jar-0.6.1 ,the problem also exist.
I'm sure my network and clientid is ok.Because i follow http://msdn.microsoft.com/en-us/library/hh454950.aspx and setup an php on my web server.It can get token and gettranslate.
That's strange.Would you help.If you have any suggestion ,please tell my .Email:[email protected].
Thanks!
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi ,
I follow the example code and it works yesterday.But tody i found Translate.excute failed always.I found Translate.execute blocks alway.I sure that my network is ok.
My code is:
Translate.setClientId(CLIENT_ID);
Translate.setClientSecret(CLIENT_SECRET);
result = Translate.execute(target, LanguageHelper.getLanguageByName(context, fromLang), LanguageHelper.getLanguageByName(context, toLang));
I had update the newest jar-0.6.1 ,the problem also exist.
I'm sure my network and clientid is ok.Because i follow http://msdn.microsoft.com/en-us/library/hh454950.aspx and setup an php on my web server.It can get token and gettranslate.
That's strange.Would you help.If you have any suggestion ,please tell my .Email:[email protected].
Thanks!
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i had registered my own app and replaced CLIENT_ID and CLIENT_SECRET in the example.It works for two days.But today,when i try to use my application,i found it failed to return from 'Translate.excute'.It just block for a long time.But I didn't modify anything.
And i'm sure that my clientid and clientsecret is valid.Because i use it to build a php page,it works.The page url is:http://platformtools.sinaapp.com/translate.php
I also try to deal with http api myself.But the problem also exists.It block on:
HttpResponse httpResponse = new DefaultHttpClient()
.execute(httpRequest);
Seem that server didn' response,but my network is ok.That's strange.
My code is :
public final static String CLIENT_ID = "translatetest55";
public final static String CLIENT_SECRET = "2+mDhC9lgXju8PRKKld7va5COr1QN3Sqjkx6vdh1rrU=";
Translate.setClientId(CLIENT_ID);
Translate.setClientSecret(CLIENT_SECRET);
String result = Translate.execute(target, LanguageHelper.getLanguageByName(context, fromLang), LanguageHelper.getLanguageByName(context, toLang));
The clientid and clientkey is which i use now.You can try it.
I try to Translate.setKey(APP_KEY) to set an old appkey and left clientid and clienk key null.Then everything works fine.But i want to use the new clientid because i'm building a new application.
Best regards
weibinke
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I tested this on my end and it worked for me with your credentials. I will see if I can think of anything else that could be wrong. In the meantime, if you are still successful using the old app ID method, you may continue using that with the same usage privileges as the Windows Azure Marketplace Apps.
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thank you very much.I think there may be something else wrong and it affect my application's network connect.
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i may found the issue:
When using new api method,we should first visit "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13" to get access token.My application run on android phone.There may be something wrong with my android device.I found it could not connect to this host.I write som code using HttpURLConnection or HttpsURLConnection to connect the url,it just return connect timeout.I try to connect to some other https url,it could connect successfully.Then i reboot my android device,and try again.Guess what?Everything is right now.
So maybe the problem is my android device.It had something problem to acess the Auth url of microsoft.After reboot ,everything seems right now,although i don't known when the network access will go wrong.
Thanks a lot for helping me.
Another question:
DatamarketAccessUri is https url ,so should we use HttpsURLConnection instead of HttpURLConnection in getToken() function?And maybe we should disable ssl vertification of the request because i am afraid of some device may have had problem on verifying the peer's certificate.See http://stackoverflow.com/questions/6681969/java-ignore-certificate-validation .
Thanks again for your great job.Your sdk is great!
private static String DatamarketAccessUri = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13";
public static String getToken(String clientId, String clientSecret)
throws Exception
{
String params = "grant_type=client_credentials&scope=http://api.microsofttranslator.com&client_id=" + URLEncoder.encode(clientId, "UTF-8") + "&client_secret=" + URLEncoder.encode(clientSecret, "UTF-8");
}
790a943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.