Join Free
Results 1 to 6 of 6

Threaded View

  1. #1

    Howto: Display top products from trends for specific query

    The following code shows you how to query the trends api endpoint with a specific query and date range. What you get back is a list of facets. We use the productID facet to pull back products from the product endpoint so we can display them on our site. Rather than pass over the products one at a time and loop through them, we pass them over as an array so everything can be done in a single query. Specificially, we pass them over to filterProductId which, as the name implies, allows us to get back the products associated with a specific list of productId's.

    PHP Code:
    $prosperentApi = new Prosperent_Api(array( 
    'filterKeyword'      => shoes,
    'commissionDateRange' => '20120101,20120701',
    'enableFacets' => 'productId'
    //fetch the result 

    //loop through productId facet and place productId's in an array we can access later
    foreach ($prosperentApi->getFacets('productId') as $productId
    $productArray[] = $productId['value'];

    //query product endpoint and pass over productId array to productId filter    
    $prosperentApi = new Prosperent_Api(array(
    'api_key'          => insertApiKeyHere,
    'filterProductId' => $productArray,
    'visitor_ip'        => $_SERVER['REMOTE_ADDR'],
    'channel_id'      => 0,
    'page'              => 1,
    'imageSize'       => '125x125',
    'limit'               => 10  
    $results $prosperentApi->fetch();
    foreach (
    $prosperentApi->getData() as $record
        <li id="serp2" class="result">
          <div class="result-body">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <td width="125px"><div style="width: 125px; height: 125px; overflow: hidden;"><a class="UrlTitleLine ui-widget-content "  
    href="<?=$record['affiliate_url']?>" dest="<?=$record['affiliate_url']?>" orig="<?=$record['affiliate_url']?>" pos="1"
    title="<?=$record['keyword']?>" ><img
     src="<?=$record['image_url']?>"  alt="<?=$record['keyword']?>" title="<?=$record['keyword']?>" width=125 height=125></a></div></td>
            <div class="url-line"> <span class="resultUrl ">
              </span> <span class="non-url"> &nbsp;&nbsp;&ndash;&nbsp; $
              <div id="tools1" class="pop-shadow-small round5 tools-pop"></div>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
coupons | coupons and deals