Foursquare api返回:远程服务器在windows phone app上返回错误(NotFound),webrequest

时间:2014-06-29 14:14:29

标签: c# windows-phone-8.1

运行Windows应用时,我的通用应用程序出现问题 它的工作原理,但运行Windows手机时,它给了我一些 错误说:远程服务器返回了 错误NotFound。我使用foursquare api搜索附近的地方

string url =" http://api.foursquare.com/v2/vanues/search?ll=" +纬度+"," +经度

 + "&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
    }

0 个答案:

没有答案