Foreword

So the other day while building a Facebook application, I needed to get some information that I just couldn’t find any way to get other than through the use of FQL  Needless to say, finding examples of FQL are plentiful.  However, examples that use FQL and the Facebook PHP SDK are not.  So I thought I’d put one together.

Getting Started

If you haven’t already done so, make sure you’ve installed the latest Facebook SDK and registered your Facebook application.

FQL And The Facebook SDK

Here’s an example call to get all the photos that belong to the logged in user:

$appInfo = array(
    'appId' => 'XXXXXXXXXXXXX',
    'appSecret' => 'XXXXXXXXXXXXXXXXXXXXX'
); 

$facebook = new Facebook($appInfo);

$result = $facebook->;api( array('method' => 'fql.query', 'query' => 'SELECT src, caption FROM photo WHERE owner=me()') );
foreach($result as $photo){
   ...
}

Conclusion

And there you have it. Hopefully this will save someone the amount of time it took for me to figure it out.


1 Comment

MK · October 21, 2012 at 10:19 pm

It did!!! I’d already put far too many hours in by the time I found your site. Thank you! Sincerely this was awesome of you. There is so little published on FQL that actually presents it in context.

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *