php - Retrieving comment count from fb:comments widget (Facebook) -
i've tried using both javascript , php sdks, can't solve simple problem.
my fql looks like:
select count comments_info xid="..." when attempt request through php, following error:
uncaught exception: 604: no valid app_id php:
$facebook = new facebook(array( 'appid' => '...', 'secret' => '...', 'cookie' => true )); $result = $facebook->api(array( 'method' => 'fql.query', 'query' => 'select count comments_info xid="'.[...].'"' )); the appid , secret copied application page in facebook developer app.
similarly, when use js api, in:
var query = fb.data.query('select count comments_info xid="' + [...] + '"'); query.wait(function(rows){}); ... same error in jsonp response:
fb.apiserver._callbacks.f2ba554518({"error_code":"604","error_msg":"no valid app_id","request_args":[{"key":"access_token","value":"[my app id]|[the actual access token]"},{"key":"api_key","value":"[my app id, again]"},{"key":"callback","value":"fb.apiserver._callbacks.f2ba554518"},{"key":"format","value":"json-strings"},{"key":"method","value":"fql.multiquery"},{"key":"queries","value":"{\"index_comments_info_xid\":\"select xid,count comments_info xid=\\\"[...]\\\"\"}"},{"key":"sdk","value":"joey"}]}); i tried recreating application several times.
at point, i've invested more hours i'd care admit :) so, if has experience problem, i'd appreciative — facebook's documentation no @ all, , dev forums pretty dead.
oops... bit of facepalm. "no valid app_id" doesn't mean application id invalid — means need specify app_id in fql query, indicated on documentation page.
here's working php example getting comment count:
require_once('facebook.php'); $facebook = new facebook(array( 'appid' => '[...]', 'secret' => '[...]' )); try { $result = $facebook->api(array( 'method' => 'fql.query', 'query' => 'select count comments_info app_id='.$facebook->getappid().' , xid="'.[...].'"' )); } catch (facebookapiexception $e) { error_log($e); }
Comments
Post a Comment