0

I am searching since 3 days and i am not successful yet

I have integrated Yelp with reference to : https://github.com/Pretz/android-example

When i run the code with all my credentials given , I get only 20 results . Am not sure where i am going wrong . Find below the code attached

new AsyncTask<Void, Void, String>() {
            @Override
            protected String doInBackground(Void... params) {
                Yelp yelp = Yelp.getYelp(YelpSearchActivity.this);
                String businesses = yelp.search("shopping", 37.788022, -122.399797);
                try {
                    return processJson(businesses);
                } catch (JSONException e) {
                    return businesses;
                }
            }

            @Override
            protected void onPostExecute(String result) {
                mSearchResultsText.setText(result);
                setProgressBarIndeterminateVisibility(false);
            }
        }.execute();

String processJson(String jsonStuff) throws JSONException {
        JSONObject json = new JSONObject(jsonStuff);
        Log.e("return data", ""+json);
        JSONArray businesses = json.getJSONArray("businesses");
        ArrayList<String> businessNames = new ArrayList<String>(businesses.length());
        for (int i = 0; i < businesses.length(); i++) {
            JSONObject business = businesses.getJSONObject(i);
            businessNames.add(business.getString("name"));
        }
        return TextUtils.join("\n", businessNames);
    }

FYI :

//Yelp.getYelp

public static Yelp getYelp(Context context) {
      return new Yelp(context.getString(R.string.consumer_key), context.getString(R.string.consumer_secret),
              context.getString(R.string.token), context.getString(R.string.token_secret));
  }

// yelp.search

public String search(String term, double latitude, double longitude) {
    OAuthRequest request = new OAuthRequest(Verb.GET, "http://api.yelp.com/v2/search");
    request.addQuerystringParameter("term", term);
    request.addQuerystringParameter("ll", latitude + "," + longitude);
    this.service.signRequest(this.accessToken, request);
    Response response = request.send();
    return response.getBody();
  }

Any related answers are welcomed . Thanks in advance .

VIGNESH
  • 2,023
  • 8
  • 31
  • 46

1 Answers1

0

Yelp's API returns only 20 results at maximum. You're not doing anything wrong, they just limit it to 20.

Obtaining more than 20 results with Google Places API

However, it seems there is a way to get up to 60 results.

Noel Bautista
  • 175
  • 1
  • 12