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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Best ways to use the ShareASale API

7,970
views

Published on

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

Published in: Technology, Business

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,970
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Best Ways to Use the API ShareASale Think Tank 2013 Eric Nagel eric@ericnagel.com
  • 2. 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
  • 3. Where to find the ShareASale API Affiliate API Under Tools Merchant API Under Tools
  • 4. 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
  • 5. 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.
  • 6. Affiliate API: Authentication HUH???? Don’t worry. 1. Click “View Sample code in PHP” 2. Copy 3. Paste 4. Change values
  • 7. 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");
  • 8. 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.
  • 9. 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); }
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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");
  • 17. 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/
  • 18. 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
  • 19. Questions? Eric Nagel Email: eric@ericnagel.com Website: www.ericnagel.com Twitter: @ericnagel