3
\$\begingroup\$

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>';
}
asked Mar 22, 2012 at 18:58
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

answered Mar 29, 2012 at 13:45
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.