I have been, or can be if you click on a link and make a purchase, compensated via a cash payment, gift, or something else of value for writing this post. Regardless, I only recommend products or services I use personally and believe will be good for my readers.
You can see an overview of Pepperjam’s Web Services at webservices.pepperjamnetwork.com . 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.
<?php set_time_limit(0); $dYesterday = date("Y-m-d", time()-86400); $cUsername = 'you@yourdomain.com'; $cPassword = 'supersecretsssshhhhh'; $cURL = 'https://webservices.pepperjamnetwork.com/?target=reports.transaction&startDate=' . $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) { print_r($rsStatData); echo("You made \$" . number_format($rsStatData[$rsMap['Commission Amount']], 2) . " from " . $rsStatData[$rsMap['Program Name']] . "\n"); } // ends while (($data = fgetcsv($fp, 1000, ",")) !== FALSE) fclose($fp); } // ends if ($fp) ?>
Let me know if you have questions! I’ll be working with Commission Junction next…