###PHP client libraries created with Mashery I/O Wraps, a semi-automated native language SDK generator.
The Whit.li API rates the relevance of people, content, and brands. Whit.li divines rare interests, personality traits, derived demographics like life stage, and more, by scanning and analyzing social media activity using complex context-sensitive pattern-matching algorithms. The result is an easy-to-compare vector set. This vector set can be used to compare two users to each other, to compare a user to a brand or to compare a user to content (like a news story). The vector set is derived from several algorithms, including natural language processing applied to user generated content (such as Facebook posts and Twitter feeds).
Head over to developer.whit.li to learn more. You can register for instant access to their API, view their documentation, and even make live API calls with their interactive docs.
An API client library (also known as an SDK or language wrapper) is an efficiency tool for programmer that helps bind external resources to your native programming language. Traditionally, to integrate an API into your project without a client library, you would need to do the following:
-
Construct a network request using a transport library (e.g. HTTP)
-
Integrate authentication flow and signatures (e.g. OAuth, MD5/SHA-256, etc.)
-
Construct and execute API calls manually, often a trial and error process while reading documentation
-
Parse through results
-
Lather. Rinse. Repeat.
Client libraries make life easier by bringing the API into your native language environment. So, rather than making curl calls, piping the output into a variable, and parsing through the variable -- the client library handles the network connectivity, authorization and API call execution with syntax you're familiar with:
// Initialize the client library
$client = new apiClient();
// Set your API key
$client->setDeveloperKey("YOUR_KEY_HERE");
// Connect client to the API
$api = new apiService($client);
// Make an API call and store the response in an object
$responseObject = $api -> KeyMethods -> Get (
"123",
"abc"
);
// Pull out the "status" value from the response payload
$status = $responseObject->getStatus();
Above is just a pseudo-PHP-code example of how this library works. If you'd like to see it in action, check out the example PHP files in this repo.
- PHP - if you'd like a quick a dirty isolated LAMP stack, check out XAMPP. Works on Mac, PC and even Linux.
- Whit.li API key -- head over to http://developer.whit.li
At Mashery, we love vim just as much as the next guy, but when it comes to tool-tips, code-completion and general object-oriented goodness, IDEs can be really useful. Eclipse, Aptana, Netbeans, Komodo, etc. They're all very mature and useful tools.
Follow the steps below for a quick start to using this client library:
-
Grab the latest source with git.
git clone git://github.com/mashery/io-wraps-whitli-php.git
-
Move the project source tree into your sandbox LAMP stack environment (anywhere below the httpdocs/htdocs level -- example code is relatively linked)
-
Head over to Whit.li to fetch an API key
-
Open up your editor and add your API key where you see YOUR_KEY_HERE on the sample PHP scripts.
-
Point your browser to one of the example files where this is deployed:
Ex: http://localhost/io-wraps-whitli-php/examples/get_key.php
- No warranty expressed or implied. Software as is.
- MIT License
- Lovingly created by Mashery Dev