tags:

views:

1317

answers:

3

I am in the process of making an app that uploads photos to Facebook and then optionally posts a link to the user's wall. I would like to know if it is possible to assign the same visibility permissions to the post as the photo or the photo album it is uploaded to. I am able to get the visibility permissions from the album fairly easily.

Is it possible to set the same permission to the wall post, and if so, how?

Clarification: I do not mean the client side permissions of the actual file. By permissions I mean the 'visibility' tag passed from the getAlbum(s) API. (i.e: Visibility: Everyone, Friends, Custom, etc)

That way, if the user sets an album to be only visible to his/her friends and they have elected to have a photo uploaded to that album that when the photo gets linked in their stream (wall) it has the same visibility settings as the album its located in.

Example: Joe creates a photo album on Facebook called "Summer Fun" that is only visible by his "Friends". Joe uses my app to upload a photo tho the "Summer Fun" album. I check the "Visibility" field of the album and see it is set to "Friends". Joe also wants a link to this photo posted to his wall, in which my app can easily do using the stream publish API. Due to his privacy setting of the "Summer Fun" album being set to "Friends" I would like my app to respect that setting when posting to the wall. Making the wall post only visible to the same group of people he calls his "Friends".

In other words, is it possible to set the group of people who can see a wall post programatically as if you were to hit the little 'Share' drop down on facebook.com and set it to 'Friends' only?

  1. Language: PHP5
  2. Using: Facebook's REST API, cURL, however open to alternatives if need be to get the end result I need.
A: 

No, it is not possible with PHP alone. The problem is that file permission attributes are not transmitted when a file is uploaded via HTTP. The only means of obtaining that information is to:

  1. ask the user
  2. run some client-side program that has access to the file system.

Unfortunately, 2 is a lot more complex than it sounds -- there are lots of client-side platforms, and most will run the browser in a security sandbox that doesn't grant access to the file system -- so you're probably better of opting for 1.

Randolpho
Thats not exactly what I meant by permissions. When you use the facebook getAlbums API it returns a 'visibility' field that says in a round-about-way who can see the photo album. Friends, Everyone, Custom, etc. I'd like to make sure that before I post a link to a photo on the user's wall that it is only viewable to those who would be able to view the photoalbum. Thus passing the same permission to the wall post (streamPublish as the album.
Jayrox
Ahh. In that case, I can't help you at the moment, as I know nothing about the facebook API. If I can find the time to research the issue today, however, I'll try to get back with more info.
Randolpho
Thanks! Does the question make more sense now? I am seeing 2 votes to close and 2 down votes. I think this is a very valid question
Jayrox
A: 

If you want to just upload photos to facebook use this :

First Download this Library facebook_php5_photoslib

Then use this code

<?php
require_once 'facebook_api/facebook_php5_photoslib.php';

$appapikey = '[YOUR KEY]';
$appsecret = '[YOUR SECRET]';
$facebook = new FacebookPhotos($appapikey, $appsecret);
$user = $facebook->require_login();

$appcallbackurl = 'http://eyermonkey.com/FlickrTools/';  

//catch the exception that gets thrown if the cookie has an invalid session_key in it
try {
  if (!$facebook->api_client->users_isAppAdded()) {
    $facebook->redirect($facebook->get_add_url());
  }
} catch (Exception $ex) {
  //this will clear cookies for your app and redirect them to a login prompt
  $facebook->set_user(null, null);
  $facebook->redirect($appcallbackurl);
}

// Get a list of the users albums
$albums = $facebook->api_client->photos_getAlbums($user, null);

// Pick the first album for sake of the example
$aid = $albums[0]['aid'];

$filename = 'http://eyermonkey.com/FlickrTools/test_image.jpg';
$caption = 'IM IN UR C0D. UPLOADING UR FOTOS!!1!';

// Perform the upload and get the return data (including the URL of the new photo)
// You can do what ever you want do with that url 
$upload_result = $facebook->api_client->photos_upload($filename, $aid, $caption);

// See the data that you have access to now that the photo is uploaded
echo '<pre>';
print_r($upload_result);
echo '</pre>';
?>
streetparade
I'm currently able to upload photos without issue. The issue I am trying to resolve is posting a link to the phone on the user's wall that includes the same privacy settings as the photo and its album.
Jayrox
+2  A: 
Sean Vieira
Sean, example A is exactly what I am trying to work around/figure out/test.When my app posts a photo and the user has selected to allow it to be cross posted to the wall I dont want people who can see his wall but cant see the album to see the wall post also. I dont know what they will see, if anything. I guess I should make a second Facebook account and test it out.
Jayrox
Also, Thanks for the additional links. I'll check them out from home tonight :)
Jayrox