Best ways to use the ShareASale API
Upcoming SlideShare
Loading in...5
×
 

Best ways to use the ShareASale API

on

  • 2,276 views

Slides from my presentation at ShareASale's Think Tank 2013 held in Denver, CO on how to use ShareASale's Affiliate API

Slides from my presentation at ShareASale's Think Tank 2013 held in Denver, CO on how to use ShareASale's Affiliate API

Statistics

Views

Total Views
2,276
Views on SlideShare
2,276
Embed Views
0

Actions

Likes
1
Downloads
9
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Best ways to use the ShareASale API Best ways to use the ShareASale API Presentation Transcript

  • Best Ways to Use the API ShareASale Think Tank 2013 Eric Nagel eric@ericnagel.com
  • What is the ShareASale API? ● API = Application Programming Interface ○ An application programming interface (API) specifies how some software components should interact with each other. ○ It’s a way for your website to talk directly to the ShareASale system ● Affiliate API ● Merchant API
  • Where to find the ShareASale API Affiliate API Under Tools Merchant API Under Tools
  • Affiliate API: Authentication The Authentication Hash Authentication Hash : SHA-256 Hash in 64 character Hex format of the string "YourAPIToken:CurrentDateInUTCFormat: APIActionValue:YourAPISecret" (without quotes) For example, for following values: Token: NGc6dg5e9URups5o API Secret: ATj7vd8b7CCjeq9yQUo8cc2w3OThqe2e String to Hash: NGc6dg5e9URups5o:Thu, 14 Apr 2011 22:44:22 GMT:bannerList:ATj7vd8b7CCjeq9yQUo8cc2w3OThqe2e UTC Date: Thu, 14 Apr 2011 22:44:22 GMT API Action: bannerList The correct HTTP Headers would be: x-ShareASale-Date: Thu, 14 Apr 2011 22:44:22 GMT x-ShareASale-Authentication: 78D54A3051AE0AAAF022AA2DA230B97D5219D82183FEFF71E2D53DEC6057D9F1
  • Affiliate API: Authentication IP Restrictions Start > Run cmd ping domain.com Gives you the IP These are the IPs that will be accessing the data. Since the script will reside on your server, use your server’s IP.
  • Affiliate API: Authentication HUH???? Don’t worry. 1. Click “View Sample code in PHP” 2. Copy 3. Paste 4. Change values
  • Affiliate API: Sample <?php $myAffiliateID = ''; Get these values from the API page $APIToken = ""; $APISecretKey = ""; $myTimeStamp = gmdate(DATE_RFC1123); $APIVersion = 1.8; We’ll get to this $actionVerb = "activity"; $sig = $APIToken.':'.$myTimeStamp.':'.$actionVerb.':'.$APISecretKey; $sigHash = hash("sha256",$sig); $myHeaders = array("x-ShareASale-Date: $myTimeStamp","x-ShareASale-Authentication: $sigHash");
  • Affiliate API: Sample $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://shareasale.com/x.cfm? affiliateId=$myAffiliateID&token=$APIToken&version=$APIVersion&action=$actionVerb"); curl_setopt($ch, CURLOPT_HTTPHEADER,$myHeaders); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, 0); $returnResult = curl_exec($ch); Nothing to do here.
  • Affiliate API: Sample if ($returnResult) { //parse HTTP Body to determine result of request if (stripos($returnResult,"Error Code ")) { // error occurred trigger_error($returnResult,E_USER_ERROR); } else{ // success echo $returnResult; } This is where you take over and put in your custom coding to do whatever you want with the data. } else{ // connection error trigger_error(curl_error($ch),E_USER_ERROR); }
  • Affiliate API ● ● ● ● ● ● ● ● ● ● Activity Details Activity Summary Merchant Timespan Report Today's Stats Monthly Summary Void Trail Traffic API Token Count Get Products Invalid Links ● ● ● ● ● ● ● ● ● ● Datafeed Merchants Coupon/Deal Merchants Merchant Status Merchant Creatives Merchant Gift Cards Edit Trail Payment Summary Merchant Search Merchant Search by Product Ledger Report
  • Example Use Activity Details to download transaction data daily and store in your tracking system or email you your commissions. Trans ID|User ID|Merchant ID|Trans Date|Trans Amount|Commission|Comment|Voided|Pendin g Date|Locked|Aff Comment|Banner Page|Reversal Date|Click Date|Click Time|Banner Id 37697968|132296|8723|10/16/2012 11:41:05 AM|323.7|71.21|Sale - 620946||||WCG45500|http://www.wineclubreviewsandratings. com/cellars-wine-club/sparkling-champagneclub-review||2012-10-16 00:00:00.0|11:34:11 AM|43027
  • Example Use Coupon / Deal Merchants to download coupons to show on your website Deal Id|Merchant Id|Merchant|Start Date|End Date|Publish Date|Title|Image(big)|Tracking URL|Image(small) |Category|Description|Restrictions|Keywords|C oupon Code|Edit Date 12104|8684|Checks Unlimited|2009-06-15 00: 00:00.0|2050-12-31 00:00:00.0|2008-08-23 18: 09:10.0|Personal checks, additional 10% off reorder check pricing.|http://|http://www. shareasale.com/u.cfm? d=12104&m=8684&u=132296|http://||Personal checks only - additional 10% off reorder check pricing default online.|||PJKA|2009-06-18 12: 26:34.0
  • Other Affiliate API Uses ● Get Products ○ Search by keyword to return products for a datafeed site ● Invalid Links ○ Make sure you’re not wasting your traffic ● Merchant Status ○ Be alerted when merchants go offline ● Merchant Creatives ○ Get the latest banners from merchants who run seasonal offers
  • What Do I Do Now? ● Process the data ○ ○ ○ See fgetcsv(), split(), explode() Save to database Send an email ● Automate your script ○ Set up a “cron” to have the script run on a regular basis ● More help? ○ ○ http://www.ericnagel.com/how-to-tips/shareasale-api.html ■ 4 years old, but it still works. http://www.ericnagel.com/how-to-tips/shareasale-prosper202.html ■ If you use Prosper202
  • Tips ● You have limited API calls. Use them wisely. ○ 200 / month = less than 7 per day i. ii. iii. iv. v. vi. Activity Details Traffic Get Products Invalid Links Coupon / Deal Merchants Merchant Status
  • Tips ● While you’re writing your script to process the data, download the data once, then use the local file for processing. This way, only 1 API call will be used. ○ $cURL = 'https://shareasale.com/x.cfm? action=couponDeals&affiliateId=132296&token=az7bFTu3LwioXNRA &XMLFormat=0'; // $cURL = 'sas.csv'; $fp = fopen($cURL, "r");
  • Tips Since we’re talking about APIs, why not combine a merchant’s direct API with the ShareASale API? ● Get data from merchant’s own API ● Change links to ShareASale Deeplinks ● … ● Profit http://www.wyzant.com/AffiliateProgram/
  • Resources ● http://blog.shareasale.com/author/ryan/ ○ Ryan Frey writes about using all the ShareASale techie things ● http://www.ericnagel.com/tag/shareasale ○ I have a few blog posts about ShareASale - keep digging ● http://www.programmableweb.com/api/shareasale-affiliate ○ Programmable Web is all things API
  • Questions? Eric Nagel Email: eric@ericnagel.com Website: www.ericnagel.com Twitter: @ericnagel