Get PID from FBID

Hits: 6790  


$APPLICATION_ID = "xxxxxxxxxxxxxxx";
$APPLICATION_SECRET = "yyyyyyyyyyyyyyyyyyyyyyyyyyyy";

$facebook = new Facebook(array(
'appId'  => $APPLICATION_ID,
'cookie' => true


$fql = "SELECT pid FROM photo WHERE object_id=".$fbid;

$param  =   array(
 'method'    => 'fql.query',
 'query'     => $fql,
 'callback'  => ''

$fqlResult   =   $facebook->api($param);

$fql = "SELECT src_small, src_big  FROM photo WHERE pid = '".$fqlResult[0]['pid']."' ";

$param  =   array(
 'method'    => 'fql.query',
 'query'     => $fql,
 'callback'  => ''

$fqlResult   =   $facebook->api($param);

echo $fqlResult[0]['src_big'];

echo "'".$fbid."' ";


Life is the art of drawing without an eraser.So be careful while taking any small decisions about the valuable pages of life.

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch

One thought on “Get PID from FBID”

  1. Hi, I’m trying to use a similar code, but even if it’s a public photo, the fql result comes empty. I was wondering if you could have any idea of why.

    Nice code, by the way ^^

Leave a Reply

Your email address will not be published.