Wednesday, May 13, 2009

Trouble with Facebook Client API

I have working on facebook application development (it's a game named Fighter Jets), and facing some weired problem. I have decided to share my experience here.

Today I tried the post link feature of the facebook API. First I tried the following code:
$facebook->api_client->links_post($user_id, 'http://khaaan.com/','Best. Website. Ever.');
I got it from their API documentation.

I got error using it. It says that 'The url you supplied is invalid'. May be it's invalid. Then I changed the URL to http://www.google.com, which is valid definitely! Still getting the same problem!! WTF!

Then I searched their forum and found that I am not the only victim, some people already faced this problem and one of them solved the problem in the following way:
$facebook->api_client->links_post('http://khaaan.com/','Best. Website. Ever.', $user_id);

Which works! Needed to use the user id as the third parameter, but from the example in the API documentation we see that it's the first parameter.

I really don't understand why the documentation is wrong.