views:

61

answers:

1

I have coded this little script, which upload a photo (images/hand.jpg) into a users profile in the default application album (in the app-album from witch im calling this script).

Now i have a problem. I would like to get the unique pid (picture id) of the just uploaded photo. When I try to echo $data, there is a int like this:

120629757986939

which appears to be the fbid of the created object:

http://www.facebook.com/photo.php?pid=115842&id=100001197451821&ref=fbx_album&fbid=120629757986939

I need this one:

.../photo.php?pid=115842&id=100001197451821&ref=fbx_album&fbid=120629757986939

Does anyone knows how to get this value? Thanks for all your help, Camillo

Below the script what i am using to upload the photo:

        $uid = $facebook->getUser();
    $me = $facebook->api('/me');
    $token = $session['access_token'];//here I get the token from the $session array
    $album_id = $album[0];

    //upload your photo
    $file= 'images/hand.jpg';
    $args = array(
    'message' => 'Photo from application',
    );
    $args[basename($file)] = '@' . realpath($file);

    $ch = curl_init();
    $url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$token;

    $data = post($url, $referer, $agent, $cookie,  $args, 1);



    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
    $data = curl_exec($ch);
A: 

If nobody comes up with a better answer here is quick and dirty solution.

If you send a request to https://graph.facebook.com/120629757986939?access_token=... you will get info about this picture, one of the fields link would contain your pid:

"link": "http://www.facebook.com/photo.php?pid=115842&id=100001197451821",

You can manually parse this url and get pid out of it.

serg
I tried this :) Graph API returned "false".Is there any tutorial where the whole process is explained?I really feel a bit dumb while stucking at this...If anyone knows where th error is/what should be added It will be really apprecited,Thanks for all your help,WSP
Camillo
@Camillo What error did it return? It shouldn't just return false, there must be some error message.
serg

related questions