这个VenuesExplore有什么问题?

时间:2014-03-18 22:23:39

标签: java foursquare

我正在尝试从以下代码获取Venue名称,但不断收到错误。很明显,该片段有一些逻辑错误。如何让它显示数据?

字符串callbackUrl =" https://developer.foursquare.com/docs/samples/explore?client_id=6666666&v=20140101&ll=43,-79&client_secret=55555555&#34 ;;

FoursquareApi foursquareApi = new FoursquareApi(clientId, client_Secret, callbackUrl);

    Result<Recommended> result = foursquareApi.venuesExplore(ll, null, null, null, null,null,query, null, null);
        if (result.getMeta().getCode() == 200) 
    {

      for (RecommendationGroup venue : result.getResult().getGroups()) 
      {
             for(Recommendation r: venue.getItems())
             {
                CompactVenue cmp = r.getVenue();
                System.out.println(cmp.getName());
             }

      }
    } 
        else 
     {
      System.out.println("Error occured: ");
      System.out.println("  code: " + result.getMeta().getCode());
      System.out.println("  type: " + result.getMeta().getErrorType());
      System.out.println("  detail: " + result.getMeta().getErrorDetail()); 
    }

运行程序时不显示任何内容。所以我猜它的逻辑错误。

1 个答案:

答案 0 :(得分:0)

I had the same error. For me it helped to change the venuesExplore() Method of the FoursquareApi.

public Result<Recommended> venuesExplore(String ll, Double llAcc, Double alt, Double altAcc, Integer radius, String section, String query, Integer limit, String basis) throws FoursquareApiException {..}

It seems that there is something wrong with the json parsing of the keywords. So I changed the:

 KeywordGroup keywords = (KeywordGroup) JSONFieldParser.parseEntity(KeywordGroup.class, response.getResponse().getJSONObject("keywords"), this.skipNonExistingFields);

to:

 KeywordGroup keywords = new KeywordGroup(); 

So no keywords in the result but the rest of the answer ist parsed right.