Many affiliate marketers don’t know how easy the use of an API program is. I have been using the CJ API service for about two weeks and have noticed an increase in revenue because of it. Since I figured out how to put it to you in Wordpress, I am going to share the code with you. First, you need to download and install the EXEC-PHP plugin for wordpress. It can be downloaded here: http://bluesome.net/post/2005/08/18/50/.

Next you will need a couple of bits of information from CJ. First, if you haven’t signed up for the CJ API service, you can sign up here: http://webservices.cj.com/. For the code to work, you will need you API number and the advertiser id. If you haven’t signed up for an advertiser that has a product catalog, now would be the time to do so.

Finally you will need to download the Nusoap library by clicking the link. Unzip it and ftp into your sites root directory.

Once you have an advertiser that has a product catalog, you need to click on the advertiser details and look at the url. In Firefox, you are not able to edit the url but rather only view it. The url will look like this: https://members.cj.com/member/1234567890/accounts/publisher/getadvertiserdetail.do?ispopup=true&advertiserId=123456.
I have highlighted the area by making the advertiser id bold and underlined. You will need to copy the number only and paste it into wordpad or some other text editor for now. You will also need to go to your account settings in CJ by clicking account. Click website settings and choose the site from the list of sites that you have entered that you will be making your post on. Once you get in here, copy the PID number and paste it in the same text editor file that you have saved the advertiser id on. Save the file for future reference.

Once you get your API number, you are ready to go.

Whenever you get the EXEC-PHP plugin installed into Wordpress, you will now need to edit the header of your theme. You can do this by clicking Appearance –>Editor. On the right hand side of the screen, you will see header. Click it. At the bottom of the code, you will need to add this snippet of code:
<?php
/*CJ API FOR WORDPRESS
COPYRIGHT (C) 2009
SCOTT P DAUGHERTY
*/
include("nusoap/lib/nusoap.php");

?>

Save the header file with this code in it. Now you will be able to add the rest of the CJ API code on each individual post just as you would the twp-auction code for ebay. Now you are ready for your API id number and advertiser id. At the end of the post that you want the cj ads on, you will insert this code:

<?php
/*
CJ API SEARCH AND RETURN
PHPPIG
COPYRIGHT (C)2009
SCOTT P DAUGHERTY
*/
//Define user information
$developerkey ="Your API key here";
$websiteIdx ="Your website id here";
$cjword = "Your keyword here";
$advertiserIds = "Your advertiser id here";
$serviceableArea = "";
$upcOrIsbnOrEan = "";
$manufacturerName = "";
$advertiserSku = "";
$lowPrice = "";
$highPrice = "";
$currency = "";
$sortBy = "";
$orderIn = "";
$startAt = 0;
$maxResultsx = 15;
$soapclient = new nusoap_client("https://product.api.cj.com/wsdl/literal_wrapped/productSearchService.wsdl", true);
$params = array(
"developerKey" => $developerkey,
"websiteId" => $websiteIdx,
"advertiserIds" => $advertiserIds,
"keywords" => $cjword,
"serviceableArea" => "",
"upcOrIsbnOrEan" => "",
"manufacturerName" => "",
"advertiserSku" => "",
"lowPrice" => "",
"highPrice" => "",
"currency" => "",
"sortBy" => "",
"orderIn" => "",
"startAt" => $startAt,
"maxResults" => $maxResultsx
);
$proxy = $soapclient->getProxy();
$result = $proxy->search($params);
$count = $result['searchReturn']['count'];
if($count > 0) {
for($i = 0; $i < $count; $i++) {
$advertiser_id = $result['searchReturn']['products']['products'][$i]['advertiserId'];
$advertiser_name = $result['searchReturn']['products']['products'][$i]['advertiserName'];
$click_url = $result['searchReturn']['products']['products'][$i]['clickUrl'];
$currency = $result['searchReturn']['products']['products'][$i]['currency'];
$description = $result['searchReturn']['products']['products'][$i]['description'];
$image_url = $result['searchReturn']['products']['products'][$i]['imageUrl'];
$name = $result['searchReturn']['products']['products'][$i]['name'];
$price = $result['searchReturn']['products']['products'][$i]['price'];
$sku = $result['searchReturn']['products']['products'][$i]['sku'];
$upc = $result['searchReturn']['products']['products'][$i]['upc'];
echo "<table border='0'><tr><td><a href='$click_url' title='$name'><font size='3'>$name";
echo "</font></a><br><font size='2'><b>$ $price </font></b>";
echo "<br>SKU: $sku";
echo "<br><a href='$click_url'><img src='$image_url' title='$name'></a>";
echo "<br><font color='#000000'>$description</font>";
echo " <br></td></tr></table><hr size='1'>";
}}
?>

At the top of the code, you will see the following:

$developerkey ="Your API key here";
$websiteIdx ="Your website id here";
$cjword = "Your keyword here";
$advertiserIds = "Your advertiser id here";

Enter the information in on the appropriate lines and insert complete code into your post. It will return the results from the advertiser that you choose with your affiliate id. For an example, visit my site at http://scottpdaugherty.com to review the code in use.