-
Notifications
You must be signed in to change notification settings - Fork 0
APIs
Arnav Gupta edited this page Jun 8, 2015
·
12 revisions
API not publicly open, but scraped from Scoot app -
private void fetchOla(String lat, String lng) {
ApplicationTaxi.getInstance().addToRequestQueue(new
AnonymousClass_14(new StringBuilder("http://mapi.olacabs.com/v3/cab/info?custom_lat=")
.append(lat).append("&custom_lng=")
.append(lng)
.append("&accuracy=10.0&fix_time=1414867768827&speed=0.0&altitude=0.0&location_type=CUSTOM&selected_by=USER&cab_category=economy_sedan&user_id=z%2FSOjdAeOaXpiu3YGpZbX4yan5NjzSyoFQ3bMhayj%2FLK11hcaHYppAIW6bxl%0AU%2BVT64RfuNjRmCF8em1tgbyD3g%3D%3D%0A++++&enable_auto=true&enable_delivery=true")
.toString(), new Listener<String>() {
public void onResponse(String response) {
VolleyLog.v("Response:%n %s", response);
ActivityHome.this.rlLoading.setVisibility(DetectedActivity.RUNNING);
try {
int i;
TaxiProviderObject t;
JSONObject resp = new JSONObject(response);
JSONArray catNames = resp.optJSONArray("city_taxi_categories");
HashMap<String, String> catNameMap = new HashMap();
for (i = 0; i < catNames.length(); i++) {
JSONObject jobj = catNames.optJSONObject(i);
if (jobj != null) {
catNameMap.put(jobj.getString("id"), jobj.getString("display_name"));
}
}
JSONArray jarr = resp.optJSONArray("cab_categories");
ArrayList<TaxiProviderObject> tempList = new ArrayList();
boolean z = false;
for (i = 0; i < jarr.length(); i++) {
jobj = jarr.optJSONObject(i);
if (jobj != null) {
t = new TaxiProviderObject();
if (jobj.optBoolean("cab_availability")) {
z = true;
t.time = new StringBuilder(String.valueOf(jobj.optJSONObject("duration").optInt("value"))).append(" mins").toString();
t.name = jobj.optString("display_name");
t.type = 3;
tempList.add(t);
}
}
}
if (z) {
t = new TaxiProviderObject();
t.isheader = true;
t.name = "Ola Cabs";
ActivityHome.this.list.add(t);
ActivityHome.this.list.addAll(tempList);
}
ActivityHome.this.adapter.notifyDataSetChanged();
ActivityHome.this.showNoCabs();
} catch (Exception e) {
e.printStackTrace();
}
}
}, new ErrorListener() {
public void onErrorResponse(VolleyError error) {
ActivityHome.this.rlLoading.setVisibility(DetectedActivity.RUNNING);
ActivityHome.this.alert("Connection Error");
}
}));
}
No public API, but as scraped from Scoot App -
private void fetchTaxiSureNew(String lat, String lng) {
ApplicationTaxi.getInstance().addToRequestQueue(new StringRequest(new StringBuilder("http://iospush.taxiforsure.com/getNearestDriversForApp/?longitude=")
.append(lng).append("&latitude=")
.append(lat).append("&density=320&appVersion=4.1.1")
.toString(), new Listener<String>() {
public void onResponse(String response) {
ActivityHome.this.rlLoading.setVisibility(DetectedActivity.RUNNING);
VolleyLog.v("Response:%n %s", response);
try {
JSONArray jarr = new JSONObject(response).optJSONObject("response_data").optJSONArray("data");
if (jarr != null && jarr.length() > 0) {
TaxiProviderObject t = new TaxiProviderObject();
t.isheader = true;
t.name = "Taxi for Sure";
ActivityHome.this.list.add(t);
}
Set<String> typeSet = new HashSet();
for (int i = 0; i < jarr.length(); i++) {
JSONObject jobj = jarr.optJSONObject(i);
if (jobj != null && !typeSet.contains(jobj.optString("carType"))) {
t = new TaxiProviderObject();
t.name = jobj.optString("carType");
t.time = new StringBuilder(String.valueOf(jobj.optInt("duration"))).append(" mins").toString();
t.type = 1;
ActivityHome.this.list.add(t);
typeSet.add(t.name);
}
}
ActivityHome.this.adapter.notifyDataSetChanged();
ActivityHome.this.showNoCabs();
} catch (Exception e) {
e.printStackTrace();
}
}
}, new ErrorListener() {
public void onErrorResponse(VolleyError error) {
ActivityHome.this.rlLoading.setVisibility(DetectedActivity.RUNNING);
ActivityHome.this.alert("Connection Error");
}
}));
}