Pepperjam Web Services

PepperjamHot on the heels of my post on how to use the ShareASale API, I recently wrote a quick script to get my Pepperjam stats & load them into my tracking database. Using the ShareASale script as a template, I was able to whip this up in about a half hour.

You can see an overview of Pepperjam’s Web Services at . For my task, I wanted to get commissions from yesterday, so I went with the Transaction Details report (I would have used Transaction Summary, but that doesn’t give the program ID, only details does).

Unlike ShareASale, Pepperjam uses your web login (email address & password) to authenticate you to the web services. I don’t like this, because if you’re a marketer & outsource your API work to a programmer, you have to hand over your login information, whereas with ShareASale, you’re authenticated by IP address, affiliate ID & API token.

Pepperjam also does not return column headers in their csv file, so you’ll have to look them up in the online documentation before you finish your script.

Here’s a simple script which grabs yesterday’s stats and outputs them. Of course, this is just to get you started… you’ll want to modify this script to do something actually useful.


	$dYesterday = date("Y-m-d", time()-86400);

	$cUsername = '';
	$cPassword = 'supersecretsssshhhhh';

	$cURL = '' . $dYesterday . '&endDate=' . $dYesterday . '&username=' . urlencode($cUsername) . '&password=' . urlencode($cPassword) . '&format=csv';

	$fp = fopen($cURL, "r");
	if ($fp) {
		$rsMap = array();
		$nIndex = 0;
		$rsMap['Transaction ID'] = $nIndex++;
		$rsMap['Order ID'] = $nIndex++;
		$rsMap['SID'] = $nIndex++;
		$rsMap['Creative Type'] = $nIndex++;
		$rsMap['Commission Amount'] = $nIndex++;
		$rsMap['Order Amount'] = $nIndex++;
		$rsMap['Transaction Type'] = $nIndex++;
		$rsMap['Transaction Date'] = $nIndex++;
		$rsMap['Transaction Status'] = $nIndex++;
		$rsMap['Program Name'] = $nIndex++;
		$rsMap['Program ID'] = $nIndex++;

		while (($rsStatData = fgetcsv($fp, 1000, ",")) !== FALSE) {

			echo("You made \$" . number_format($rsStatData[$rsMap['Commission Amount']], 2) . " from " . $rsStatData[$rsMap['Program Name']] . "\n");
		} // ends while (($data = fgetcsv($fp, 1000, ",")) !== FALSE)
	} // ends if ($fp)

Let me know if you have questions! I’ll be working with Commission Junction next…

How To & Tips
Share this Story:
  • facebook
  • twitter
  • gplus

Leave a comment