Getting Commission Junction’s API to work

Getting Commission Junction’s API to work

I have seen a few posts on various affiliate forums that attempt to help in getting the Commission Junction (CJ) API working. The API allows one to access the data feed from an advertiser on CJ, for use on their own website. There are many things that you can do once you have that data but the tricky part is getting the API to work in the first place.

Whilst the CJ API documentation is thorough it doesn’t provide any examples for developers to use. The following PHP example for version 2 of their API will get you up and running in no time at all.


$website_id = ‘YOUR-WEBSITE-ID-NUMBER’;
$advertiser_ids = ‘joined’; // Specify which advertisers products you want, here I use the shortcode joined for only those programs that I have actually joined
$keywords = ‘stapler’; // Keyword search – find all products that have the word stapler in their title

$url = ‘’ . $website_id . ‘&advertiser-ids=’ . $advertiser_ids . ‘&keywords=”‘ . $keywords . ‘”‘;

// For testing, to make sure the $url is correct
// echo $url;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, FALSE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Authorization: ‘ . $api_key));

$curl_results = curl_exec($ch);


// For testing, to make sure XML data is sent back (when echo’ing, to the browser. you would normally then use SimpleXML to process further before displaying)
// echo $curl_results;


Oliver Partridge

Building websites since 2000, I have a wealth of experience in eMarketing, SEO, e-mail marketing and social media marketing. Google+ and Twitter

1 Comment

  1. rajib chowdhury says:

    After using this code i do not get any output.
    I try to print result using
    echo $curl_results;
    I have not find any result. Then i used following code
    die(‘Error: “‘ . curl_error($ch) . ‘” – Code: ‘ . curl_errno($ch));
    It’s print me this
    Error: “SSL certificate problem: unable to get local issuer certificate” – Code: 60
    I am not sure how can i integrate cj api in my project

Leave a Reply

  • Your Weight Loss Challenge Website Build

    Portfolio Situation The client is a distributor of Herbalife products. A 12-week slimming challenge course is to be offered with the ability for people to

  • How to use Paid On Results Data Feeds in a Website

    Website Design & Development

    This tutorial uses SymphonyCMS to control the XML product feeds, so you should have that installed first. The Paid on Results feeds are standard, we

  • Script for obtaining consent for cookiesScript for obtaining consent for cookies

    Script for obtaining consent for cookies

    Website Design & Development

    The implementation time limit for the new EU privacy directive requirement for getting consent for cookies on websites is fast approaching to May 2012 Related