I am new at facebook development using their PHP-SDK and Graph API. I am at the stage that I need to find which road should I take for a better/faster and efficient results.
I display the pages a user administrates in both ways. My question is which one should I choose?
Thank you community.
Using Facebook PHP-SDK
require 'src/facebook.php';
$results = $facebook->api('/fql', array('q'=>'SELECT page_id FROM page_admin WHERE uid = me()'));
foreach($results['data'] as $result) {
echo $result['page_id'], '<br />';
}
Using CURL & Graph Api
$query = "SELECT page_id FROM page_admin WHERE uid = me()";
$encodedQuery = urlencode($query);
$url = "https://graph.facebook.com/fql?q=".$encodedQuery."&access_token=".$_SESSION['fb_100515270076928_access_token'];
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$results = curl_exec($ch);
$results = json_decode($results);
foreach ($results->data as $result) {
echo $result->name, '<br>';
}
1 Answer 1
I think you'd be better off using the official API wrapper from Facebook. If they ever change their APIs you could download the latest version of their wrapper and continue on.
The best thing you can do for speed is cache the results. PHP can read files on the server a lot faster than downloading the information with CURL.