Go Back   Discuss New York > Discuss New York Interests > Member Blogs


New York Pass

Using the ShareASale API

Member Blogs


Reply
 
LinkBack Thread Tools Display Modes
Old Monday, November 2nd, 2009   #1
NYS Tour Guide
 
esnagel's Avatar
 
Join Date: Nov 2007
Location: Kenmore
Age: 31
Posts: 1,429
Thanks: 139
Thanked 654 Times in 390 Posts
Send a message via ICQ to esnagel Send a message via AIM to esnagel Send a message via MSN to esnagel Send a message via Yahoo to esnagel Send a message via Skype™ to esnagel
Default Using the ShareASale API


There are plenty of things you can do via the ShareASale website, including running reports, getting links, and keeping updated on current offers. But when you’re dealing with dozens, or hundreds, of merchants, you can really increase your productivity by harnessing the power of the ShareASale API.

To get started, login to ShareASale and open the API Reporting page (found under Tools). In the section labeled IP Addresses and Token Key, you’ll need to enter the IP of your server. The easiest way to do this is to ping your domain name from the windows command line (or, ask your hosting provider). The token is your password to access the API.

Authentication to the ShareASale API is done via a combination of userID, IP address, and Token. Finally, select which actions you want your account activated for (transaction reports, creative reports, and / or merchant reports).

The section on the right, labeled Report Parameters, gives an idea of what can be done with the ShareASale API. In this example, I’ll be working with the merchantStatus action, and using PHP to gather the information & work further with it.

First, we need to build the URL. All URLs start with https://shareasale.com/x.cfm, followed by the parameter list.

$cURL = 'https://shareasale.com/x.cfm?version=1.1 &action=merchantStatus &affiliateId=yourID &token=yourToken &programStatus=online &XMLFormat=0';This will return the following columns:
Merchant Id, Merchant, WWW, Program Status, Program Category, Sale Comm, Lead Comm, Hit Comm, Approved, Link Url

The first line returned contain the column headers, and the rest of the file contains the data. As usual with ShareASale, fields are pipe (|) delimited.

First, the variable $rsMap is created, to hold the column headings and their index (place in line). Then, the file is read and once data is found, $rsMap is populated. In this example, $rsMap looks like:

Array( [Merchant Id] => 0 [Merchant] => 1 [WWW] => 2 [Program Status] => 3 [Program Category] => 4 [Sale Comm] => 5 [Lead Comm] => 6 [Hit Comm] => 7 [Approved] => 8 [Link Url] => 9)After $rsMap is filled up, the script continues to read lines, saving them in $rsMerchant. If the line isn’t empty (which the last line is always empty, so we have this check put in place) and the Merchant name isn’t empty (I found 1 Merchant who doesn’t have a name – not sure if this has been fixed yet), you can work with this data. For example, if you want to use the Merchant name, it’s saved in $rsMerchant[$rsMap['Merchant']]. The Merchant’s URL is saved in $rsMerchant[$rsMap['WWW']] and your affiliate link is $rsMerchant[$rsMap['Link Url']].

Geek stuff
I use $rsMerchant[$rsMap['Link Url']] to make the code easier to use, but the nested associative arrays may confuse some people, so let’s break it down.
$rsMap['Link Url'] is 9 (see above), so $rsMerchant[$rsMap['Link Url']] translates to $rsMerchant[9], which is the 10th column of data (start counting at 0).

Now you could use this to pull all merchants from a particular category (category=fam, or category=fud (see the ShareASale site for list of categories & their values)) and create a page with just merchants from this category. You’d want to save this data, and recreate it daily, or weekly, as you are limited to 200 requests per month (I run 3 queries, every day, using up about 100 queries / month).

Tip
While you’re developing your script, save the entire result from ShareASale and save it as a .csv file. Then, make your script read the .csv file, not the ShareASale URL. This way, you only use 1 API request as you develop your script. You can see where I use this in the script below.

Here’s a script which pulls the merchant list, and outputs the data you can work with:

0 [Merchant] => 1 [WWW] => 2 [Program Status] => 3 [Program Category] => 4 [Sale Comm] => 5 [Lead Comm] => 6 [Hit Comm] => 7 [Approved] => 8 [Link Url] => 9 ) */ while (($rsMerchant = fgetcsv($fp, 1000, "|")) !== FALSE) { if ( (md5(serialize($rsMerchant)) != '5b448a7bdbeea0be7d7f758f5f8ee90b') && !empty($rsMerchant[$rsMap['Merchant']]) ) { print_r($rsMerchant); } // ends else from if ($rsLinkData = mysql_fetch_array()) } // ends } // ends while (($data = fgetcsv($fp, 1000, "|")) !== FALSE) fclose($fp); } // ends if ($fp)?>I use the ShareASale API to get yesterday’s stats and load it into my custom tracking script, so I know ROI per merchant. My script runs daily (sometime before I wake up in the morning) and request yesterday’s statistics. Here’s the URL:

$dYesterday = date("m/d/Y", time()-86400);$cURL = 'https://shareasale.com/x.cfm?action=activity&affiliateId=yourID&token=you rToken&dateStart=' . $dYesterday . '&dateEnd=' . $dYesterday . '&XMLFormat=0';As I work with more & more merchants in the ShareASale network, automating these tasks has saved me countless hours of manual labor.

If you have questions, feel free to leave a comment or email me!




Using the ShareASale API

esnagel is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebooktwitter
Reply With Quote
Old Monday, November 2nd, 2009   #2
Local Legend
 
Raven's Avatar
 
Join Date: Dec 2007
Location: In a bird house
Posts: 5,317
Thanks: 932
Thanked 1,383 Times in 1,020 Posts
Send a message via Yahoo to Raven
Default Re: Using the ShareASale API

Could you look at the front of KDT website. A organization is having a event that and some of the proceeds are going to KDT. I of coarse had to advertise it on the website. The google checkout donation button ended up huge. How can I make it smaller.
Raven is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebooktwitter
Reply With Quote
Old Wednesday, November 4th, 2009   #3
NYS Tour Guide
 
esnagel's Avatar
 
Join Date: Nov 2007
Location: Kenmore
Age: 31
Posts: 1,429
Thanks: 139
Thanked 654 Times in 390 Posts
Send a message via ICQ to esnagel Send a message via AIM to esnagel Send a message via MSN to esnagel Send a message via Yahoo to esnagel Send a message via Skype™ to esnagel
Default Re: Using the ShareASale API

The problem is in one of the 8 CSS files referenced from your site. As the image itself, https://checkout.google.com/buttons/...text&loc=en_US, is fine
esnagel is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebooktwitter
Reply With Quote
The Following User Says Thank You to esnagel For This Useful Post:
Raven (Wednesday, November 4th, 2009)
Reply

Thread Tools
Display Modes




All times are GMT -4. The time now is 03:40 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

Serveware