{"id":605,"date":"2012-05-06T03:44:10","date_gmt":"2012-05-06T03:44:10","guid":{"rendered":"http:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/?p=605"},"modified":"2015-03-04T06:26:31","modified_gmt":"2015-03-04T06:26:31","slug":"api-capturing-a-lead-via-http-get-or-post","status":"publish","type":"post","link":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605","title":{"rendered":"API &#8211; Capturing a Lead via HTTP GET or POST"},"content":{"rendered":"<p><strong><span style=\"color: #ff0000;\">This documentation is only for developers. If you are not a developer with good PHP coding skills then you have no need to read this.<\/span><\/strong><\/p>\n<p>This documentation explains how you can capture a lead from your own script using the API of the affiliate plugin. If you want to use this API then you need to enable it from the settings menu of the affiliate plugin first. The following is a screenshot of this section in the settings menu:<\/p>\n<div id=\"attachment_607\" style=\"width: 510px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-607\" class=\"size-full wp-image-607\" title=\"wp-affiliate-api-remote-post-settings\" src=\"http:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png\" alt=\"\" width=\"500\" height=\"275\" srcset=\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png 500w, https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings-300x165.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><p id=\"caption-attachment-607\" class=\"wp-caption-text\">Additional Integration Options Screenshot<\/p><\/div>\n<p>Once you enable it, you can start to send request to the specified URL from your script to capture lead remotely.<\/p>\n<p>You need a minimum of 3 pieces of information to capture a lead using a HTTP request. These are:<\/p>\n<ul>\n<li>Secret word (the secret word that you have specified in the settings)<\/li>\n<li>Referrer ID (the affiliate ID of the referrer who sent this visitor your way)<\/li>\n<li>Email address of the lead\/customer<\/li>\n<\/ul>\n<p>Optionally, you can pass in the following additional data too:<\/p>\n<ul>\n<li>A reference value (this can help you identify the source if you are capturing lead from multiple places<\/li>\n<li>IP address of the lead<\/li>\n<\/ul>\n<h3>1. Capturing Lead via HTTP GET request<\/h3>\n<p>To capture a lead via HTTP GET use the following format:<\/p>\n<pre>\r\nhttp:\/\/www.example.com\/wp-content\/plugins\/wp-affiliate-platform\/api\/remote-lead-capture.php?secret=XX&ap_id=YY&buyer_email=ZZ\r\n<\/pre>\n<p>Replace the &#8220;example.com&#8221;, &#8220;XX&#8221;, &#8220;YY&#8221;, &#8220;ZZ&#8221; with the appropriate value.<\/p>\n<h4>PHP Code Example<\/h4>\n<p>The following is an example of how to construct this link using PHP:<\/p>\n<pre>\r\n$secret = \"4bd39e2e4a7bb\";\r\n$referrer = \"aff21\";\r\n$email = \"jon.doe@yahoo.com\";\r\n$prepared_data = \"?secret=\".$secret.\"&amp;ap_id=\".$referrer.\"&amp;buyer_email=\".$email;\r\n$get_url = \"http:\/\/www.example.com\/wp-content\/plugins\/wp-affiliate-platform\/api\/remote-lead-capture.php\".$prepared_data;\r\n\/\/ Execute this GET Request\r\nfile_get_contents($get_url);\r\n<\/pre>\n<h3>2. Capture Lead via HTTP POST request<\/h3>\n<p>To capture lead via HTTP POST use the following format:<\/p>\n<pre>\r\n&lt;form method=\"post\" action=\"http:\/\/www.example.com\/wp-content\/plugins\/wp-affiliate-platform\/api\/remote-lead-capture.php\"&gt;\r\n&lt;input type=\"hidden\" name=\"secret\" value=\"XX\"&gt;\r\n&lt;input type=\"hidden\" name=\"ap_id\" value=\"YY\"&gt;\r\n&lt;input type=\"hidden\" name=\"buyer_email\" value=\"ZZ\"&gt;\r\n&lt;input type=submit value=\"Submit Post\"&gt;\r\n&lt;\/form&gt;\r\n<\/pre>\n<p>Replace the &#8220;example.com&#8221;, &#8220;XX&#8221;, &#8220;YY&#8221;, &#8220;ZZ&#8221; with the appropriate value.<\/p>\n<h4>PHP Code Example<\/h4>\n<p>If you are integrating the affiliate platform plugin with a script written in PHP then you can add the following example code to capture the lead when your script executes:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/code-examples\/php-example-capture-lead-http-post.txt\" target=\"_blank\">Example code to capture lead using HTTP POST method<\/a><\/li>\n<\/ul>\n<h3>How to\u00a0Programmatically\u00a0Retrieve the Affiliate ID on a Page<\/h3>\n<p>If you are writing a script then you most likely want to code it up so the affiliate ID can be retrieved programmatically. The affiliate ID is stored in the cookie so just retrieve the value form the cookie. For example the following code will give you the affiliate ID if used in PHP:<\/p>\n<pre>\r\n$affiliate_id = $_COOKIE['ap_id'];\r\n<\/pre>\n<p>Now, you can use the &#8220;$affiliate_id&#8221; variable in your script.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This documentation is only for developers. If you are not a developer with good PHP coding skills then you have no need to read this. This documentation explains how you can capture a lead from your own script using the API of the affiliate plugin. If you want to use this API then you need [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[12,3],"tags":[11,37,38],"class_list":{"0":"post-605","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-3rd-party-cart-integration","7":"category-additional-resources","8":"tag-3rd-party-integration","9":"tag-affiliate-platform-api","10":"tag-capture-lead-remotely","11":"entry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>API - Capturing a Lead via HTTP GET or POST - WordPress Affiliate Platform<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#\/schema\/person\/b3a690506213824832751de546a340fb\"},\"headline\":\"API &#8211; Capturing a Lead via HTTP GET or POST\",\"datePublished\":\"2012-05-06T03:44:10+00:00\",\"dateModified\":\"2015-03-04T06:26:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605\"},\"wordCount\":392,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png\",\"keywords\":[\"3rd party Integration\",\"Affiliate Platform API\",\"Capture lead remotely\"],\"articleSection\":[\"3rd Party Cart Integration\",\"Additional Resources\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605\",\"url\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605\",\"name\":\"API - Capturing a Lead via HTTP GET or POST - WordPress Affiliate Platform\",\"isPartOf\":{\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png\",\"datePublished\":\"2012-05-06T03:44:10+00:00\",\"dateModified\":\"2015-03-04T06:26:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#\/schema\/person\/b3a690506213824832751de546a340fb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage\",\"url\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png\",\"contentUrl\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png\",\"width\":\"500\",\"height\":\"275\",\"caption\":\"Additional Integration Options Screenshot\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#website\",\"url\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/\",\"name\":\"WordPress Affiliate Platform\",\"description\":\"Take control of your affiliates and drive more sales\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#\/schema\/person\/b3a690506213824832751de546a340fb\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/3a21ab4072e533cf470d80fc2f0fd3639872824ade4e23709397e109b24f8857?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3a21ab4072e533cf470d80fc2f0fd3639872824ade4e23709397e109b24f8857?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3a21ab4072e533cf470d80fc2f0fd3639872824ade4e23709397e109b24f8857?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"API - Capturing a Lead via HTTP GET or POST - WordPress Affiliate Platform","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#article","isPartOf":{"@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605"},"author":{"name":"admin","@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#\/schema\/person\/b3a690506213824832751de546a340fb"},"headline":"API &#8211; Capturing a Lead via HTTP GET or POST","datePublished":"2012-05-06T03:44:10+00:00","dateModified":"2015-03-04T06:26:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605"},"wordCount":392,"commentCount":0,"image":{"@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage"},"thumbnailUrl":"http:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png","keywords":["3rd party Integration","Affiliate Platform API","Capture lead remotely"],"articleSection":["3rd Party Cart Integration","Additional Resources"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605","url":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605","name":"API - Capturing a Lead via HTTP GET or POST - WordPress Affiliate Platform","isPartOf":{"@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage"},"image":{"@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage"},"thumbnailUrl":"http:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png","datePublished":"2012-05-06T03:44:10+00:00","dateModified":"2015-03-04T06:26:31+00:00","author":{"@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#\/schema\/person\/b3a690506213824832751de546a340fb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/api-capturing-a-lead-via-http-get-or-post-605#primaryimage","url":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png","contentUrl":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-content\/uploads\/2010\/04\/wp-affiliate-api-remote-post-settings.png","width":"500","height":"275","caption":"Additional Integration Options Screenshot"},{"@type":"WebSite","@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#website","url":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/","name":"WordPress Affiliate Platform","description":"Take control of your affiliates and drive more sales","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/#\/schema\/person\/b3a690506213824832751de546a340fb","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3a21ab4072e533cf470d80fc2f0fd3639872824ade4e23709397e109b24f8857?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3a21ab4072e533cf470d80fc2f0fd3639872824ade4e23709397e109b24f8857?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3a21ab4072e533cf470d80fc2f0fd3639872824ade4e23709397e109b24f8857?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/posts\/605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/comments?post=605"}],"version-history":[{"count":0,"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/posts\/605\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/media?parent=605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/categories?post=605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tipsandtricks-hq.com\/wordpress-affiliate\/wp-json\/wp\/v2\/tags?post=605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}