views:

1475

answers:

2

I've set up a Facebook application, I've requested the extended permissions and now I'm trying to upload a photo but it doesn't work!

I've tried everything, from

$facebook->api_client->photos_upload('photo/789165784.jpg');

To

$facebook->api_client->photos_upload('photo/789165784.jpg', NULL, 'My photo', 100000287894654);

I'm beginning to suspect that I need to set up some extensions for php. I'm using WAMP and since the server is currently offline, I can't test it on production until tomorrow (I think..).

Thanks!

+2  A: 

I don't know too much about this, I'm afraid, but the following link suggests that other people have had the same problem. Maybe this forum will be helpful:

http://forum.developers.facebook.com/viewtopic.php?pid=93450

It also links to this page, which seems like it might help:

http://wiki.auzigog.com/Facebook_Photo_Uploads

Ben

Ben
Kinda odd, that topic is back from May. I found one from two years ago ( http://forum.developers.facebook.com/viewtopic.php?pid=119294 ) in which it seems the uploads are working.Nevertheless thanks, I will be waiting if someone knows what is happening with FB :)
metrobalderas
A: 

Here are some various ways to upload photos using the Graph API. The examples assume you've instantiated the $facebook object and have a valid session for the current user.

1 - Default Application Album of Current User

This example will upload the photo to your default application album of the current user. If the album does not yet exist it will be created.

$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/me/photos', 'post', $args);
print_r($data);

2 - Target Album

This example will upload the photo to a specific album.

$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/'. $ALBUM_ID . '/photos', 'post', $args);
print_r($data);

3 - Target Album with Access Token

This example will upload a photo to a specific album which requires an access token.

 $args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/'. $ALBUM_ID . '/photos?access_token='. $ACCESS_TOKEN, 'post', $args);
print_r($data);