If you think the Android project bv-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.bazaarvoice.example.browseproducts;
/*www.java2s.com*/import com.bazaarvoice.types.*;
import com.bazaarvoice.BazaarRequest;
import com.bazaarvoice.DisplayParams;
import com.bazaarvoice.OnBazaarResponse;
/**
* BazaarFunctions.java <br>
* ReviewSubmissionExample<br>
*
* <p>
* This is a suite of functions that leverage the BazaarvoiceSDK. This class
* consolidates the usage of these functions for easier understanding of how to
* use the SDK.
*
* <p>
* Created on 6/29/12. Copyright (c) 2012 BazaarVoice. All rights reserved.
*
* @author Bazaarvoice Engineering
*
*/publicclass BazaarFunctions {
publicstaticfinal String API_URL = "reviews.apitestcustomer.bazaarvoice.com/bvstaging";
publicstaticfinal String API_KEY = "kuy3zj9pr3n7i0wxajrzj04xo";
publicstaticfinal ApiVersion API_VERSION = ApiVersion.FIVE_FOUR;
/**
* Sends off a product query with the search term provided.
*
* @param searchPhrase
* the search term(s)
* @param listener
* the response listener
*/publicstaticvoid runProductSearchQuery(String searchPhrase,
OnBazaarResponse listener) {
BazaarRequest request = new BazaarRequest(API_URL, API_KEY, API_VERSION);
DisplayParams params = new DisplayParams();
if (!"".equals(searchPhrase.trim())) {
// Add search terms to params
String[] tokens = searchPhrase.split("\\s+");
for (String term : tokens) {
params.setSearch(term);
}
}
params.addStats(IncludeStatsType.REVIEWS);
request.sendDisplayRequest(RequestType.PRODUCTS, params, listener);
}
/**
* Sends off a reiview query for the given product Id. It sorts the results
* by rating from highest to lowest.
*
* @param prodId
* the product id
* @param listener
* the response listener
*/publicstaticvoid runReviewQuery(String prodId, OnBazaarResponse listener) {
BazaarRequest request = new BazaarRequest(API_URL, API_KEY, API_VERSION);
DisplayParams params = new DisplayParams();
params.addFilter("ProductId", Equality.EQUAL, prodId);
params.setLimit(10);
// false => descending order
params.addSort("Rating", false);
OnBazaarResponse response = listener;
request.sendDisplayRequest(RequestType.REVIEWS, params, response);
}
}