uberVU is a conversation engine which aggregates conversations from social websites around specific URLs. They track services like:
- Twitter / FriendFeed
- Digg / Reddit/ Hacker News
- Major blogging platforms (Wordpress, Blogger, MT, Typepad etc)
- Major video sharing websites (Youtube, Vimeo)
- Flickr / Picasa
- Disqus
Like any decent web based service uberVU are making an API available for us developers to play around with the capabilities of their system. I decided that, in the absence of anybody else doing it (and as a nice little coding exercise for myself), I would build a php library for using the uberVU API.
In order to use the library, you will need to register for a developer account and apply for an API key, go to http://developer.ubervu.com/ to get started.
How to use it
Include the ubervu.php file
The basic ubervu object is constructed using only the api key as a parameter:
<?php
include('ubervu.php');
$uv = new ubervu("[my api key]");
?>
the ubervu object contains 3 methods:
- getUrlInfo(string url)
- addUrl(string url)
- addUrls(mixed urls)
the urls parameter can be either a comma delimited string or an array
Each method returns a uv_response object this has 2 basic properties; data and info.
The data property contains properties parsed from the ubervu api response, the info property contains information returned from the api call made by cURL.
uv_Response Object ( [data] => stdClass Object ( ... //returned data object ) [info] => Array ( [url] => http://api.ubervu.com/1.0/resources/?url=[url]&apikey=[apikey]&format=json [content_type] => application/json [http_code] => 200 [header_size] => 256 [request_size] => 150 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.427589 [namelookup_time] => 0.029885 [connect_time] => 0.119761 [pretransfer_time] => 0.119851 [size_upload] => 0 [size_download] => 744 [speed_download] => 1739 [speed_upload] => 0 [download_content_length] => 744 [upload_content_length] => 0 [starttransfer_time] => 0.427436 [redirect_time] => 0 ) )
The info property should be useful in determining whether a call has failed due to unavailability of the API e.g. [http_code] == 404
Get Information about a URL
<?php
$uv = new ubervu("[my api key]");
$data = $uv->getURLInfo("http://mydomain.com/page");
?>
Add a URL for tracking
<?php
$uv = new ubervu("[my api key]");
$data = $uv->addUrl("http://mydomain.com/page");
?>
Add a number of URLs for tracking
<?php
$uv = new ubervu("[my api key]");
$data = $uv->addUrls("http://mydomain.com/page ,http://mydomain.com/page2 ,http://mydomain.com/page3");
?>
you can also pass an array of URLs into this method
<?php
$urls = array("http://mydomain.com/page");
array_push ($urls,"http://mydomain.com/page2");
array_push ($urls,"http://mydomain.com/page3");
$uv = new ubervu("[my api key]");
$data = $uv->addUrls($urls);
?>
at the time of writing there is possibly a minor issue with the batch add method but the uberVU team are all over it.
That’s all for now
I’ll try to refine this library as development on the uberVU API continues, who knows, maybe I’ll even move it to proper project hosting and write better documentation for it. In the meantime play with the demo, the view code link at the bottom of any result set will help you to see what’s going on.
Drop me a line if you have any questions, suggestions or to let me know about something you’ve used the library for.
Update
This project is now listed on PHP Classes and Freshmeat.net.
Tweet This
Digg This