Facebook API calls break page?
I'm trying to connect to the PHP SDK and retrieve a comment count from an fb:comments plugin I'm using on a project. However, when I try to make a $facebook->api() FQL call it always breaks my page. No error, just no more page processing past the API call.
require_once 'scripts/fb-api/facebook.php';
$facebook = new Facebook(array(
'appId' => '2开发者_运维技巧22725974406020',
'secret' => '---'
));
$result = $facebook->api(array(
'query' => 'SELECT post_id FROM comment WHERE xid = 0',
'method' => 'fql.query'));
var_dump($result);
I've used the exact same code in another project that may be using an older version of the Facebook SDK and it works. Did something change recently?
I'm also dealing with the change in fb:comments from xid's to href's. I don't see any FQL documentation on how to handle comments using an href... any advice on how to pull that data would be awesome.
If this is something that requires you to see the page, I'd be happy to provide you with a link.
Thanks!
Try catching the errors, it helps considerably in debuging and ensuring your page doesn't crash:
require_once 'scripts/fb-api/facebook.php';
$facebook = new Facebook(array(
'appId' => '222725974406020',
'secret' => '---'
));
try {
$result = $facebook->api(array(
'query' => 'SELECT post_id FROM comment WHERE xid = 0',
'method' => 'fql.query'));
} catch (Exception $e) { echo "ERROR: ".$e; }
var_dump($result);
精彩评论