I’m facing a strange problem right now…
I’m trying to use Facebook API to gather some informations on users on my App, which I can but the returning string is weird..
Here is what I have :
$params = array("method" => "fql.query",
"query" => "SELECT first_name, last_name FROM user WHERE uid = $this->userId",
"callback" => null);
$result = json_decode($oFbSmarty->getFacebookApi()->api($params));
$this->setFirstName($result->first_name);
$this->setLastname($result->last_name);
var_dump($result);
And here is the result of the var_dump :
string 'null([{"first_name":"Alexandre","last_name":"\u30b4\u30c7\u3093\u30b7\u30aa"}]);' (length=80)
Did someone ever face this ?
I can’t understand why there is a “null” writtent in the returning string…
Thanks !
EDIT :
Well… Actually it’s worse than what I thought =/
the “null” part of the response string is here because I didn’t fill the “callback” part of the params but put null instead.
Doing that makes facebook api automatically return an ready-to-execute string, which means :
If I had type “sayPlop” as callback function, returned string would have been =>
"sayPlop(......)"
So if you don’t wan’t facebook to do that, just don’t specify the “callback” parameter, it’s optionnal (see Facebook PHP SDK source code).
Thanks !
It looks like it’s not passing the JSONP callback, I’m not familiar with the Facebook API but change your $params to this and it will wrap it differently.
I think you must define a function called myfunctionname to process the data.