Question

I am using this code for fql query to get user insights for the page he admins.

    $fql  = "SELECT metric, value FROM insights WHERE object_id=". $url . " AND metric='page_fans_country' AND end_time=1398665793 AND period=2592000";
    $apifql="https://api.facebook.com/method/fql.query?format=json&query=".urlencode($fql);
    $lc_json=file_get_contents($apifql);
    $lc = json_decode($lc_json);

It throws error 104 and this error code says I must use access token while I have read_insights permission also.

Was it helpful?

Solution

you can get access token by using facebook object and just embed it to your fql query

<?php
    $token = $facebook->getAccessToken();
    $apifql="https://api.facebook.com/method/fql.query?format=json&query=".urlencode($fql)."&access_token=".$token;
?>

OTHER TIPS

You should use the

GET https://graph.facebook.com/fql?q=...

endpoint as described here (https://developers.facebook.com/docs/technical-guides/fql/#read). This should do the trick:

$apifql="https://graph.facebook.com/fql?q=".urlencode($fql)."&access_token=".$facebook->getAccessToken();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top