Get PID from FBID

On June 12, 2011, in Facebook, Tricks, by Sandeep Verma

Hits: 1509  
<?php

include("lib/facebook.php");

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

$facebook = new Facebook(array(
'appId'  => $APPLICATION_ID,
'secret' => $APPLICATION_SECRET,
'cookie' => true
));

$fbid="xxxxxxxxxx";

$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'];
print_r(getimagesize($fqlResult[0]['src_big']));

echo "http://www.facebook.com/photo.php?fbid='".$fbid."' ";

?>

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



  • Sophia Coelho

    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 ^^

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...