A PHP client for the Raven Tools API.
This source code for the client is licensed under the terms found in the LICENSE
file therein. This library is not produced by Raven Tools or its parent company.
- Interacts with the Raven Tools API for managing websites, keywords and links
Full class documentation is available in the /docs
folder of the repository after running phpdoc
(requires separate installation), which can be viewed in any web browser by opening the index.html
page. In its most basic example:
// Create an object from the class using your API key
require 'path/to/raventools-api-php/src/class.raven-api-php.php';
use \RavenToolsApi;
$Raven = new \RavenTools\RavenToolsAPI( 'YOUR_API_KEY' );
// Make a request using one of the provided methods
$domains = $Raven->GetDomains();
// $domains now contains a list of domains (websites) in the Profile
// associated with the provided API key
By default, the library will return PHP objects/arrays as API responses. Any of the convenience methods (e.g. GetDomains
, GetKeywords
, AddLinks
) will always return in this manner such as in the example above. Additionally, direct output can be obtained by using one of the three methods below.
$objectOrArray = $Raven->get($method, $options);
$jsonString = $Raven->getJSON($method, $options);
$xmlString = $Raven->getXML($method, $options);
$method
(string) - Name of the API method; see the Raven Tools API Documentation$options
(array) - URL parameters to pass to the given method.
Outbound requests are checked for required fields based prior to sending the API request. If a required parameter is missing or blank, an exception will be thrown. Additionally, malformed or empty responses from the API will also throw an exception. It is recommended that you wrap API keys in try
/catch
constructs.
try {
$domains = $Raven->GetDomains();
} catch (Exception $e) {
// Do something in the event of an exception
print 'Error: ' . $e->getMessage();
exit;
}
An API Key is required for interating with the Raven Tools API. Users can generate an API Key for each 'Profile' in their account. These instructions detail how to get an API key within the platform.