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 |

can you help please i
can you help please
i installed the oauth package but the project dosen't work
can you help to know haow to configure this class and use into this project
thx
Hi, I just downloaded you
Hi,
I just downloaded you code from http://github.com/ndejong/PHP-Freelancer.com-API-Wrapper and i use my key and secret. It gives me the following error:
Fatal error: Class ‘OAuth’ not found in …………\freelancer.php on line 76
Although I added Oauth.php class from http://oauth.net/code/
Hi, I can help you improve
Hi,
I can help you improve this, I like to help. I forked your git repo and made first change, next thing is sorting out the echo's, not a problem. Get in touch. The fork now works without having to manual do it, it's raw and basic but it's also a small seed in the form of an idea. you can handle curl output as it is structured, now you have a control mechanism. I have lot's of experience building console php apps and that is where I'll use your work ;-)
Hi Jeff, no sorry I do not -
Hi Jeff, no sorry I do not - I'd be happy to work with you to straighten out the wrapper though - the transaction calls are not yet implemented with this version...
you have any full-blown
you have any full-blown examples of this I could test?
Post new comment