.. include:: _include.rst .. highlight:: php .. _php_functions_api_requests: ############################ API requests ############################ This page contains information about |asa2| PHP functions you can use in your scripts to manually send requests to the Amazon Product Advertising API. ************************** Asa2_Service::itemLookup ************************** Deprecated :strike:`Asa2_Service::itemLookup` Use :ref:`php_function_asa2_item_lookup` instead. .. _php_function_asa2_item_lookup: ************************** asa2_item_lookup ************************** This function lets you work directly with an ASA 2 item object. You can access all placeholder keys as public properties. Description ----------- .. code:: php `_ for more details. .. image:: _static/button_api_doc.png :height: 76px :width: 255px :scale: 100% :alt: ASA2 API documentation :target: http://docs.getasa2.com/api/function-asa2_item_lookup.html Parameters ---------- asin The ASIN of the product you want to render options An array of :ref:`shortcodes_asa2_options` (same as for the :ref:`shortcodes_asa2` shortcode). - ``ajax`` Set to 1 activate the AJAX mode - ``country_code`` The product's country code - ``no_cache`` Set to 1 to bypass the cache - ``tpl`` The template name - ``tplid`` The template ID - ``tracking_id`` Custom tracking ID Examples -------- Based on the custom field "asin" this code tries to create an ASA 2 item object by using the ``asa2_item_lookup()`` function. You can check if the result is a valid object by using function ``asa2_is_item_object()``. On a valid item object you can access all :ref:`placeholders` as public properties. For example, if you want to access the item's title, known as placeholder ``{{ Title }}``, use ``$item->Title``. .. code:: php ID, 'asin', true); if (!empty($asin)) { $tplid = get_post_meta($post->ID, 'tplid', true); $options = array(); if (!empty($tplid)) { $options['tplid'] = $tplid; } $item = asa2_item_lookup($asin, $options); if (asa2_is_item_object($item)) { // it is an ASA 2 item object echo '

' . $item->Title . '

'; printf('', $item->SmallImageURL, $item->SmallImageWidth, $item->SmallImageHeight); echo 'List price: ' . $item->ListPriceFormattedPrice . '
'; echo 'Current price: ' . $item->OffersMainPriceFormattedPrice . '
'; echo $item->CustomerReviewsImgTag; } }