Difference between revisions of "Offerit API"
OfferitJames (talk | contribs) |
OfferitDave (talk | contribs) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 11: | Line 11: | ||
== Authentication == | == Authentication == | ||
− | The Offerit API uses HTTP Authentication where the username is the Affiliate username and the password is the Affiliate API key. To retrieve | + | The Offerit API uses HTTP Authentication where the username is the Affiliate username and the password is the Affiliate API key. |
+ | |||
+ | '''Note:''' ''Affiliates do not start with an API key and you will have to manually create one for each affiliate that wants access to the API. In addition, API access is only available to admin-level affiliates.'' | ||
+ | |||
+ | To retrieve an API key for an affiliate, go to the Affiliates admin and click "View/Change API Key". On the next page, you can create an API key for the user you clicked on by clicking "Generate API Key". | ||
== Example == | == Example == | ||
Line 20: | Line 24: | ||
require_once('nusoap/lib/nusoap.php'); | require_once('nusoap/lib/nusoap.php'); | ||
− | $url = 'http:// | + | $url = 'http://offerit.site.com/admin_api.php'; // change to be the domain of your Offerit install |
$username = 'OFFERITADMIN'; // your admin username | $username = 'OFFERITADMIN'; // your admin username | ||
$apikey = 'afsb35gh8j3rgasfdgja9r8ebja59gb8'; // your api key | $apikey = 'afsb35gh8j3rgasfdgja9r8ebja59gb8'; // your api key | ||
Line 37: | Line 41: | ||
− | To give a complete example of this, here's an example using the [[ | + | To give a complete example of this, here's an example using the [[Offerit_API_Ping|Ping]] function. This is how to call it: |
<pre> | <pre> | ||
<? | <? | ||
require_once('nusoap/lib/nusoap.php'); | require_once('nusoap/lib/nusoap.php'); | ||
− | $url = 'http://offerit.site.com/admin_api.php'; // change to be the domain of your | + | $url = 'http://offerit.site.com/admin_api.php'; // change to be the domain of your Offerit install |
$username = 'offeritadmin'; // your admin username | $username = 'offeritadmin'; // your admin username | ||
$apikey = 'afsb35gh8j3rgasfdgja9r8ebja59gb8'; // your api key | $apikey = 'afsb35gh8j3rgasfdgja9r8ebja59gb8'; // your api key | ||
Line 56: | Line 60: | ||
} | } | ||
− | $result = $client->call('ping', Array(), ' | + | $result = $client->call('ping', Array(), 'offeritapiadmin_wsdl'); |
var_dump($result); | var_dump($result); | ||
</pre> | </pre> | ||
Line 64: | Line 68: | ||
bool(true) | bool(true) | ||
</pre> | </pre> | ||
− | |||
− |
Latest revision as of 21:09, 28 January 2014
The Offerit API is accessible at http://<domain>/admin_api.php
- Replace <domain> with your Offerit install domain name.
Gaining Access to the Admin API
In order to access Offerit API, your IP address must be in the ADMIN_API_ALLOWED_IPS list. You can add or remove IP addresses to this list via the Configurations Admin under the "Security" tab.
If you're also using ADMIN_IPS to restrict access to your admin, you must also add the IP to that list, as this is also an admin page.
Authentication
The Offerit API uses HTTP Authentication where the username is the Affiliate username and the password is the Affiliate API key.
Note: Affiliates do not start with an API key and you will have to manually create one for each affiliate that wants access to the API. In addition, API access is only available to admin-level affiliates.
To retrieve an API key for an affiliate, go to the Affiliates admin and click "View/Change API Key". On the next page, you can create an API key for the user you clicked on by clicking "Generate API Key".
Example
The easiest way to use SOAP when using PHP is using the NuSOAP Toolkit. Assuming you've downloaded the toolkit into a directory called nusoap, here is an example of how to connect:
<? require_once('nusoap/lib/nusoap.php'); $url = 'http://offerit.site.com/admin_api.php'; // change to be the domain of your Offerit install $username = 'OFFERITADMIN'; // your admin username $apikey = 'afsb35gh8j3rgasfdgja9r8ebja59gb8'; // your api key $client = new nusoap_client($url.'?wsdl', true); $client->setCredentials($username,$apikey); // Check for an error $err = $client->getError(); if ($err) { // Display the error echo 'Constructor error' . $err . "\n"; exit; // At this point, you know the call that follows will fail }
To give a complete example of this, here's an example using the Ping function. This is how to call it:
<? require_once('nusoap/lib/nusoap.php'); $url = 'http://offerit.site.com/admin_api.php'; // change to be the domain of your Offerit install $username = 'offeritadmin'; // your admin username $apikey = 'afsb35gh8j3rgasfdgja9r8ebja59gb8'; // your api key $client = new nusoap_client($url.'?wsdl', true); $client->setCredentials($username,$apikey); // Check for an error $err = $client->getError(); if ($err) { // Display the error echo 'Constructor error' . $err . "\n"; exit; // At this point, you know the call that follows will fail } $result = $client->call('ping', Array(), 'offeritapiadmin_wsdl'); var_dump($result);
And this is the output:
bool(true)