The guys over at Freelancer.com have produced an API to interact with their already cool site. Their API is well documented and easy enough to use but there are a few hoops to jump through to get an application authorized and and the response data structures do not always seem consistent among all the possible calls (but that could just be me).
To simplify things further I've created a PHP wrapper class to assist in using the Freelancer.com API.
For example, you can do the following:-
include_once('freelancer.php');
$freelancer = new Freelancer(CONSUMER_KEY,CONSUMER_SECRET);
$freelancer->authorize();
print_r($freelancer->getAccountDetails());
The most enjoyable magic performed by this PHP class is all the authorize magic that "just works" so you don't have to worry about getting down into the details of OAuth to get things to work.
Keep in mind this is a first v0.1 release and I do expect bugs to exist so if you find them PLEASE be sure to report them.
Some things to keep in mind and things that could be improved:-
- Authentication tokens are by default stored as JSON encoded files in the /tmp path which means you'll loose them when your /tmp folder gets purged at reboot - you can pass parameters to the authorize() method to specify the token file to use.
- Output from the Class needs to be better handled, it's all currently just echoed out which means it's not ideal for a web app right now - workable though.
- Need to work out a clean way to hand off to http://www.sandbox.freelancer.com/users/api-token/auth.php and manage the call back -- this process is currently manual as you'll discover
- Need to implement all the Payment API calls
Tarfile attached herewith -- or better still head over to github and grab it:-
http://github.com/ndejong/PHP-Freelancer.com-API-Wrapper
Enjoy,
N
| Attachment | Size |
|---|---|
| Freelancer_v0.1.tar_.gz | 5.54 KB |








Post new comment