- Initialize SDK
- Album Features
- How to get image urls
- Album Analytics
- Ecommerce Analytics
- UI components
- Migration
- Before accessing any Pixlee API, you must initialize the
PXLClient
. To set the API key, call the static method initialize:Or:java// If you need only to use @Get APIs #!java PXLClient.initialize(<PIXLEE API KEY>);
// If you need to use both @Get and @Post APIs #!java PXLClient.initialize(<PIXLEE API KEY>, <PIXLEE SECRET KEY>);
- You can then use the singleton instance to make calls against the Pixlee API:
#!java PXLClient client = PXLClient.getInstance(context);
-
To load the photos in an album, you'll want to use the
PXLAlbum
class. Instantiate one with your album ID and client:#!java PXLBaseAlbum album = new PXLAlbum(<ALBUM ID>, client);
Or:
#!java PXLBaseAlbum album = new PXLAlbum(<ALBUM ID>, client.getBasicDataSource(), client.getAnalyticsDataSource());
-
To load the photos in an Product album, you'll want to use the
PXLPdpAlbum
class. Instantiate one with your desired sku and client:#!java PXLBaseAlbum album = new PXLPdpAlbum(<SKU>, client);
Or:
#!java PXLBaseAlbum album = new PXLPdpAlbum(<SKU>, client.getBasicDataSource(), client.getAnalyticsDataSource());
- You can then set sort and filter options if desired and use
loadNextPageOfPhotos
to kick off the async request.#!java PXLAlbumFilterOptions filterOptions = new PXLAlbumFilterOptions(); filterOptions.minTwitterFollowers = 1000; filterOptions.minInstagramFollowers = 2000; PXLAlbumSortOptions sortOptions = new PXLAlbumSortOptions(); sortOptions.sortType = PXLAlbumSortType.DYNAMIC; sortOptions.descending = true; album.setPerPage(15); album.setFilterOptions(filterOptions); album.setSortOptions(sortOptions); album.loadNextPageOfPhotos(this);
- Each successive call of
loadNextPageOfPhotos
will load the next page of photos. Be sure to set all of your request options (filters, sort, etc) before callingloadNextPageOfPhotos
. See the source for more implementation details. Once an album has loaded photos from the server, it will instantiatePXLBaseAlbum
objects that can be consumed by your UI.PXLBaseAlbum
exposes all of the data for a photo available through the Pixlee API and offers several image url sizes depending on your needs.
-
Prerequisite:
- Initiate Album or Product
- prepare PXLBaseAlbum and declare a variable as 'album'
-
Option 1: Upload an image url
#!java album.uploadImage( "<image URL>", "<title>", "<email>", "<name>", <true/false>, ["productA", "productB"], ["Clothing", "Shoes"], {"shirt_size": "M"}, new PXLBaseAlbum.RequestHandlers<MediaResult>() { @Override public void onComplete(MediaResult result) { // process the result } @Override public void onError(String error) { // error } });
-
Option 2: Upload an image file
album.uploadLocalImage( "<local image path>", "<title>", "<email>", "<name>", <true/false>, ["productA", "productB"], ["Clothing", "Shoes"], {"shirt_size": "M"}, new PXLBaseAlbum.RequestHandlers<MediaResult>() { @Override public void onComplete(MediaResult result) { // process the result } @Override public void onError(String error) { // error } });
Some imageURL fields can be empty or null depending on its data's status. In order to get appropriate images, you can use this method.
#!java
photo.getUrlForSize(PXLPhotoSize.ORIGINAL)
photo.getUrlForSize(PXLPhotoSize.BIG)
photo.getUrlForSize(PXLPhotoSize.MEDIUM)
photo.getUrlForSize(PXLPhotoSize.THUMBNAIL)
Be aware of the difference between Opened Widget and Widget Visible. (Need a sample code. Check the demo app in the project)
There is an order of firing these two APIs.
- Opened Widget: You should fire this when firing the api is done and loading the photo data into your own view for the widget is complete.
- Widget Visible: Opened Widget should be fired first. Then, you can fire this when your own view for the widget started to be visible on the screen.
-
-
To fire this event, simply call the
openedWidget
method of the PXLAlbum or PXLPdpAlbum AFTER data has been returned from the first call of theloadNextPageOfPhotos
method, and an "Opened Widget" event will be fired containing all of the necessary analytics information. See the onComplete function in GalleryFragment.java for an example.#!java album.openedWidget(PXLWidgetType.photowall); album.openedWidget(PXLWidgetType.horizontal); album.openedWidget("<Customized name>");
-
-
-
To fire this event, simply call the
widgetVisible
method of the PXLAlbum or PXLPdpAlbum AFTER data has been returned from the first call of theloadNextPageOfPhotos
method, and an "Widget Visible" event will be fired containing all of the necessary analytics information.#!java album.widgetVisible(PXLWidgetType.photowall); album.widgetVisible(PXLWidgetType.horizontal); album.widgetVisible("<Customized name>");
-
- To fire a load more event, simply call the
loadMore
method of the PXLAlbum or PXLPdpAlbum AFTER data has been returned from calls via the 'loadNextPageOfPhotos' method, a "Load More" analytics event will be fired containing all of the necessary analytics information. See the onComplete function in GalleryFragment.java for an example. - On calls to loadNextPageOfPhotos (except the first), a "Load More" analytics event will be fired automatically
#!java album.loadMore();
-
To fire an opened ligtbox event, simply call the
openedLightbox
method of the PXLBaseAlbum that is being opened, and an "Opened Lightbox" event will be fired containing all of the necessary analytics information.#!java album.openedLightbox(photo.albumPhotoId) album.openedLightbox(photo)
-
To fire an action clicked event, simply call the
actionClicked
method of the PXLBaseAlbum that the action click is being driven from and pass in the URL of the link that the user is being redirected to. An "Action Clicked" event will be fired containing all of the necessary analytics information.#!java album.actionClicked(photo.albumPhotoId, "https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html"); album.actionClicked(photo, "https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html");
- initialize:
Or:
#!java PXLAnalytics analytics = new PXLAnalytics(client);
#!java PXLAnalytics analytics = new PXLAnalytics(client.getAnalyticsDataSource());
-
To fire an Add To Cart event, simply call the
addToCart
method of the PXLAnalytics object with the necessary parameters, and an "Add To Cart" event will be fired containing all of the necessary analytics information. The parameters for this method are:- [Required] sku (String)
- [Required] price (String)
- [Required] quantity (Integer)
- [Optional] currency (String)
#!java analytics.addToCart("sku123", "123", 4);
-
To fire a Conversion event, simply call the
conversion
method of the PXLAnalytics object with the necessary parameters, and a "Conversion" event will be fired containing all of the necessary analytics information. The parameters for this method are:- [Required] cartContents (ArrayList<HashMap<String, Object>>)
- [Required] cartTotal (String)
- [Required] cartTotalQuantity (Integer)
- [Optional] orderId (String)
- [Optional] currency (String)
#!java ArrayList<HashMap<String, Object>> cartContents = new ArrayList(); HashMap<String, Object> cart1 = new HashMap(); cart1.put("price", "123"); cart1.put("product_sku", "test123"); cart1.put("quantity", "4"); cartContents.add(cart1); analytics.conversion(cartContents, "123", 4);
- after receiving PXLPhoto list via PXLBaseAlbum.loadNextPageOfPhotos(...), you can launch watch the content using PXLPhotoViewerActivity. Depending on its content_type, PXLPhotoViewerActivity will play a video or display a photo.
- you can use the activity using the code here
#!java PXLPhotoViewerActivity.launch(getContext(), pxlPhoto, "photo name"); PXLPhotoViewerActivity.launch(getContext(), pxlPhoto);
pixlee-android-sdk is available under the MIT license.