#Readability API This is an API wrapper of the Readability API to use in PHP.
##external Libraries This wrapper uses the OAuth Library which is under the MIT License. It also uses the curl wrapper which is also under MIT License.
##Requirements ###Readability API Key You need an API Key from Readability. You can Request one at their contact page ###cURL In order to make HTTP-Request this Lib uses the cURL PHP Extension. Other wrapper are planned.
##Usage Initiate the object with your token and secret:
$api = new Kanedo_Readability("consumer_token", "consumer_secret");
To use the lib you first have to authorize yourself with readability. In order to do this you have to make three requests.
-
The authorization (The user give permission) You have to redirect to the authorization page and provide a callback URL.
$api->authorize("http://example.org/callback");
-
Request a token
$result = $api->request_token($_REQUEST['oauth_verifier'], $_REQUEST['oauth_token'], $_REQUEST['oauth_callback_confirmed']);
Readability will send three parameters when redirecting back to your callback url - we need this params
-
Access token
$token = $api->access_token($result);
This method returns an OAuthToken object. You can either store it or, if you only use this single instance, you can just forget it ;-)
-
Request some information
In order to do that I've implemented an method calledmakeAPIRequest($url, array $params = NULL, OAuthToken $aToken = NULL)
The first param is the URL (to access the base url you can use the propertyapi_base
) the second is an array of parameters - it can beNULL
. The last parameter is the OAuthToken. If you use a single instance (in which case the token is stored inside the object) you can leave this blank, otherwise you to provide the object which was returned byaccess_token()
.
The methodmakeAPIRequest
returns unparsed JSON - you can do what ever you want to.
It's planned to encapsulate everything in special methods likegetFavorites
.
##Method documentation In this section you can learn how to use special methods ###getFavorites Retrieves favorited bookmarks in an optional given timeframe ####Parameter
- $start timestamp begin of the timeframe (optional)
- $end timestamp end of the timeframe (optional)
- $aToken OAuthToken the acces token (optional)
####Return value
- array Returns an array of objects. For details see Readability API Documentation
##Feedback If you want to get in touch with me, visit my blog at http://blog.kanedo.net. I would like to hear from you. Especially if you find a bug or something like that!