C# Foursquare api返回:远程服务器在windows phone应用程序上返回了一个错误(NotFound),webrequest
运行windows应用程序时,我的通用应用程序出现问题 它可以工作,但当运行windows phone one时,它会给我一些帮助 错误提示:远程服务器返回了一个 找不到错误。我正在使用foursquare api搜索附近的地方 字符串url=”“+纬度+”,“+经度C# Foursquare api返回:远程服务器在windows phone应用程序上返回了一个错误(NotFound),webrequest,c#,windows-phone-8.1,C#,Windows Phone 8.1,运行windows应用程序时,我的通用应用程序出现问题 它可以工作,但当运行windows phone one时,它会给我一些帮助 错误提示:远程服务器返回了一个 找不到错误。我正在使用foursquare api搜索附近的地方 字符串url=”“+纬度+”,“+经度 + "&radius=1000&limit=20&client_id=GEDT5VBHXZ0PASW3VQMHABRG0MQK2N41QNEJJNMWPOYZBEHZ& client_
+ "&radius=1000&limit=20&client_id=GEDT5VBHXZ0PASW3VQMHABRG0MQK2N41QNEJJNMWPOYZBEHZ&
client_secret=Q5SHT204LFIZLPCJPFNTVVAOESYLWJPQ2MBQSKWCZ4D2XQWQ&v=20130815";
WebRequest GETRequest = WebRequest.Create(url);
GETRequest.Method = "GET";
// TextBlk.Text = "Getting The Data.....";
try
{
using (var GETResponse = await GETRequest.GetResponseAsync())
{
using (var GETResponseStream = GETResponse.GetResponseStream())
{
StreamReader sr = new StreamReader(GETResponseStream);
string st = sr.ReadToEnd();
// TextBlk.Text = st;
JsonObject JO = JsonObject.Parse(st);
JsonObject obj = JO.GetNamedObject("response");
for (i = 0; i < 20; i++)
{
JsonArray arr = obj.GetNamedArray("venues");
lastObj = arr.GetObjectAt(i);
JsonObject locationObject = lastObj.GetNamedObject("location");
lat = locationObject.GetNamedNumber("lat");
lan = locationObject.GetNamedNumber("lng");
Color c = Color.FromArgb(69, 5, 179, 156);
TextBlock t = new TextBlock();
t.Width = 300;
t.Text = lastObj.GetNamedString("name");
t.FontSize = 22;
t.TextAlignment = TextAlignment.Center;
t.HorizontalAlignment = HorizontalAlignment.Center;
t.VerticalAlignment = VerticalAlignment.Center;
var item = new GridViewItem { Background = new SolidColorBrush(c), Content = t, Width = 300, Height = 120, Foreground = new SolidColorBrush(Colors.White) };
gridview1.Items.Add(item);
mainProgressRing.Visibility = Visibility.Collapsed;
mainProgressRing.IsActive = false;
}
gridview1.SelectionChanged += ListView_SelectionChanged;
}
}
}
catch (WebException exception)
{
message = new MessageDialog(exception.Message);
}
await message.ShowAsync();
//end of the web service receiving
}
+”&radius=1000&limit=20&client_id=gedt5vbhxz0pasw3vqmhabrg0mqk2n41qnejjmwpoyzbehz&
客户_secret=Q5SHT204LFIZLPCJPFNTVVAOESYLWJPQ2MBQSKWCZ4D2XQWQ&v=20130815”;
WebRequest GETRequest=WebRequest.Create(url);
GETRequest.Method=“GET”;
//Text blk.Text=“获取数据…”;
尝试
{
使用(var GETResponse=await GETRequest.GetResponseAsync())
{
使用(var GETResponseStream=GETResponse.GETResponseStream())
{
StreamReader sr=新的StreamReader(GETResponseStream);
字符串st=sr.ReadToEnd();
//Text blk.Text=st;
JsonObject JO=JsonObject.Parse(st);
JsonObject obj=JO.GetNamedObject(“响应”);
对于(i=0;i<20;i++)
{
JsonArray arr=obj.GetNamedArray(“场馆”);
lastObj=arr.GetObjectAt(i);
JsonObject locationObject=lastObj.GetNamedObject(“位置”);
lat=locationObject.GetNamedNumber(“lat”);
lan=locationObject.GetNamedNumber(“lng”);
颜色c=颜色。来自argb(69,5179156);
TextBlock t=新的TextBlock();
t、 宽度=300;
t、 Text=lastObj.GetNamedString(“名称”);
t、 FontSize=22;
t、 TextAlignment=TextAlignment.Center;
t、 水平对齐=水平对齐.居中;
t、 垂直对齐=垂直对齐。中心;
var item=new-GridViewItem{Background=new-solidcolorbush(c),Content=t,Width=300,Height=120,front=new-solidcolorbush(Colors.White)};
gridview1.Items.Add(项目);
mainProgressRing.Visibility=可见性。已折叠;
mainProgressRing.IsActive=false;
}
gridview1.SelectionChanged+=ListView\u SelectionChanged;
}
}
}
捕获(WebException异常)
{
message=新建MessageDialog(exception.message);
}
等待消息。ShowAsync();
//web服务接收结束
}
如果在正在测试的设备或模拟器上打开internet explorer,是否可以浏览到internet页面?我猜您没有连接到internet,这就是为什么会出现“未找到”错误。我检查了internet,但它确实连接了,但现在它在visual studio上弹出此对话框。我无法上传图片来向您展示,但您可以使用此链接pdb文件是visual studio在调试时可以从中获取有关应用程序的一些信息的文件。我将清理解决方案并再次尝试调试。我也会尝试不同的坐标,以确保它不是4正方形,在你经过的坐标附近没有找到任何东西。谢谢你,在我清理项目后,它起作用了,你是我的英雄。