tags:

views:

297

answers:

2

Is there a way I can post photos to my facebook profile using my username and password only? The code may be in PHP or Java. Can I use the facebook java api, if yes how? I dont want to make a facebook app and allow it to post photos to my profile.
Any help is much appreciated. Thanks in advance.

A: 

Have a look at Facebook java api, particularly FeedUserPhoto and FeedFacebookPhoto classes.

folone
+1  A: 

Here are some various ways to upload photos using the PHP 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);