Updated V3 example to retrieve a single product

Updated to V3 – To retrieve a single product based on Awins product ID, the code is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
    require_once('constants.inc.php');
    require_once('classes/class.ClientFactory.php');
    $oClient = ClientFactory::getClient();
    $returnedcolumns = array(sAwImageUrl,sDescription,sBrand,iMerchantId,iCategoryId);
    $getProductparams = array('iProductId'	=> 42063671, "sColumnToReturn" => $returnedcolumns, "iAdult" => 1);
    $getProduct= $oClient->call('getProduct', $getProductparams);
    $gpsAwImageUrl = $getProduct->oProduct->sAwImageUrl;
    $gpiCategoryId = $getProduct->oProduct->iCategoryId;
    $gpsName = $getProduct->oProduct->sName;
    $gpsDescription = $getProduct->oProduct->sDescription;
    $gpfPrice = $getProduct->oProduct->fPrice;
    $gpsAwDeepLink = $getProduct->oProduct->sAwDeepLink;
    $gpsBrand = $getProduct->oProduct->sBrand;
    $gpiMerchantId = $getProduct->oProduct->iMerchantId;
    echo '<img src="'.$gpsAwImageUrl.'"/ style="float:left; margin:10px;border:0;" alt="'.$gpsName.'" title="'.$gpsName.'"/>';
    echo $gpsDescription.'<br/><br/><h5>&pound;'.number_format($gpfPrice,2,'.',',').'</h5>'.$gpsBrand.'<br/><br/';
    echo '<a href="'.$gpsAwDeepLink.'" target="_blank" rel="nofollow">Click to see details</a>';
 
	?>

Comments

6 Comments on Updated V3 example to retrieve a single product

  1. emmfield on Tue, 8th Dec 2009 1:36 pm
  2. Don’t forget you need the define(‘API’, ‘PS’); at the top of the script. Also, I adapted your “Get a list of merchants” script for V3, it’d be cool if you could make a page for it, thanks!

    97, ‘iMaxResult’ => 10, ‘sColumnToReturn’ => $returnedcolumns);
    $oResponse = $oClient->call(‘getMerchantList’, $listmerchants);
    foreach($oResponse->oMerchant as $details){
    $logo = $details->sLogoUrl;
    $name = $details->sName;
    $strapline = $details->sStrapline;
    $description = $details->sDescription;
    $showurl = $details->sDisplayUrl;
    $deeplink = $details->sClickThroughUrl;
    $id = $details->iId;

    if ($logo”) {
    echo ““;
    }
    }

    ?>

  3. apimonkey on Tue, 8th Dec 2009 2:15 pm
  4. Ah, you see the define(’API’, ‘PS’); is included in the constants.inc.php file, so, there’s no need for it in the top of any particular code example, as long as the two required files are included

    require_once(‘constants.inc.php’);
    require_once(‘classes/class.ClientFactory.php’);

    The code you have there is incomplete, but, I will add a page later for the merchant list.

  5. emmfield on Tue, 8th Dec 2009 2:29 pm
  6. Yeah, I forgot the code tags – tried to delete the comment and repost but couldn’t :)

  7. apimonkey on Tue, 8th Dec 2009 2:44 pm
  8. If you mail me the code, I’ll change it on your comment

    admin@awinapi.com

  9. apimonkey on Tue, 8th Dec 2009 2:55 pm
  10. I’ve created a new page for V3 Get Merchant List

  11. emmfield on Fri, 11th Dec 2009 3:12 pm
  12. The new page looks great, thanks.

    I’m looking to return only the cheapest priced product for a particular query and also build a price comparison table.

    For example, display the cheapest merchant along with an image, description and price for an ipod nano.

    For the comparison, just a simple table in ascending price order, with columns showing the merchant, details, price, p+p and the buy link. Do you know if either of these would be possible? Thanks a lot.

Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

You must be logged in to post a comment.