这是我第一次为 wp7 编写代码,但我遇到了一些麻烦。当我声明token_req = "http://api.server.com/oauth/token"时没问题,但是当我声明 * https时,它无法连接,所以我得到“远程服务器返回错误:未找到。” 在线错误
WebResponse 响应 = (HttpWebResponse)request.EndGetResponse(result);
const string results
private void button1_Click(object sender, RoutedEventArgs e)
{
string token_req = "https://api.server.com/oauth/token";
string client_id = "...";
string client_secret = "...";
string username = Field_Login.Text;
string password = Field_Password.Password;
string token_req_param = "grant_type=password&client_id=" + client_id + "&client_secret=" + client_secret + "&username=" + username + "&password=" + password;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(token_req+"?"+token_req_param);
request.BeginGetResponse(GetCallback, request);
}
void GetCallback(IAsyncResult result)
{
WebRequest request = (HttpWebRequest)result.AsyncState;
WebResponse response = (HttpWebResponse)request.EndGetResponse(result);
using (StreamReader httpwebStreamReader = new StreamReader(response.GetResponseStream()))
{
results = httpwebStreamReader.ReadToEnd();
}
response.Close();
}
此外,我无法使用 IE 连接到此 url,而我使用 wp7 模拟器。=\