[英]WebClient same request works on WinForms but doesn't work on WP7
Here is my code: 这是我的代码:
var client = new WebClient();
client.Headers[HttpRequestHeader.Authorization] = "Basic " + "SECRETCODE";
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded; charset=UTF-8";
client.Headers[HttpRequestHeader.Host] = "api.quizlet.com";
client.UploadStringCompleted += ClientOnUploadStringCompleted;
client.UploadStringAsync(new Uri("https://api.quizlet.com/oauth/token"), "POST", string.Format("grant_type={0}&code={1}&redirect_uri={2}",
HttpUtility.HtmlEncode("authorization_code"), HttpUtility.HtmlEncode(code), HttpUtility.HtmlEncode(AfterOAuthUrl)));
When I test this code in WinForms, I recieve proper token, but when I use this on WP7, it throws exception: Remote server returned: "Not found". 当我在WinForms中测试此代码时,我收到了正确的令牌,但是当我在WP7上使用它时,它会抛出异常:远程服务器返回:“未找到”。 What should I do?
我该怎么办? Is this the WP certificate problem, or do I have to do something different on WP7?
这是WP证书问题,还是我必须在WP7上做一些不同的事情?
Okay... Try the following: 好的...尝试以下方法:
client.Headers[HttpRequestHeader.Referer] = "http://api.quizlet.com";
If that doesn't work: 如果这不起作用:
client.Headers[HttpRequestHeader.Referer] = "api.quizlet.com";
In the WP project. 在WP项目中。 Let me know if it doesn't work.
如果它不起作用,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.