尝试用HttpWebRequest获取Gmail联系人的分组信息,但是总是报异常 The remote Server returned an error:not found
不知道怎么回事,这段代码在pc上跑是没有问题的,但是移植到wp7上就出问题了,希望高手速度来解救!
public void GetGroups()
{
HttpWebRequest request = WebRequest.Create("https://www.google.com/m8/feeds/groups/default/full?v=3.0") as HttpWebRequest;
request.Method = "GET";
request.Headers[HttpRequestHeader.Authorization] = "GoogleLogin auth=" + AuthToken;
request.BeginGetResponse(new AsyncCallback(GetGetGroupsResponse), request);
}
public void GetGetGroupsResponse(IAsyncResult result)
{
try
{
HttpWebRequest req = result.AsyncState as HttpWebRequest;
HttpWebResponse resp = req.EndGetResponse(result) as HttpWebResponse;
if (resp.StatusCode == HttpStatusCode.OK)
{
Stream s = resp.GetResponseStream();
StreamReader sr = new StreamReader(s);
AllGroups = XElement.Load(XmlReader.Create(resp.GetResponseStream()));
PraseGroupXML();
if (GetGroupsCompleted != null)
{
GetGroupsCompleted(this, new EventArgs());
}
}
foreach (GroupAllInfo info in groupAllInfo)
{
Debug.WriteLine(info.title);
}
}
catch (System.Exception ex)
{
if (ErrorEvent != null)
{
ErrorEvent(ex.Message, new EventArgs());
}
}
}
远程服务器返回了一个错误:未找到
意思是,服务器问题。
估计原因是Google检测到你是在移动设备上。。。
虽然帮助不是很大 但是还是谢谢回复了
是否是因为https的原因?