Check Photo privacy for a user - facebook

My project is a Facebook application developed in asp.net MVC3. I want to check the privacy of a Facebook photo for a particular user.
I have Facebook userid and Facebook photo path. How can I check whether this user had permission to view this photo?

I finally found a solution for this issue. By using fql we can query all the privacy details of an object from table "privacy":
SELECT value, description FROM privacy WHERE id = 10150146071791729.
From here we can get privacy details of an fb object; please see this documentation reference.
But the one issue still exist is that I am unable to check the privacy of a fb photo whose owner is not my friend. I am still searching for that.

Found Graph API solution for getting privacy settings, but it's providing privacy settings of albums not for particular photos.
https://graph.facebook.com/me?fields=id,name,albums.fields(privacy)&access_token=ACCESS_TOKEN

Related

Trying to get the privacy settings for an app using Facebook Graph API

I am using the Javascript SDK to log in to facebook and request 'publish_actions' permissions for my application. I have everything working and can post photos to my application no problem. I use my own dialog to let them set a comment and set privacy setting to "Just Me", "Friends" or "Public".
When a user first attempts to connect to facebook from my web app, they are asked to set the privacy setting level when posting photos (Just Me, Friends, Public, etc). The issue I am having is that I want to be able to get that information later when the user posts a photo through my app so I can see what privacy setting are available for my dialog. For example:
A user logs in to my app and for publish_actions chooses "Friends" as the privacy setting. Later on if they are running my app, I give them a choice to pick "Only Me", "Friends" or "Public" but I need to know that "Public" is not allowed for that user. Currently if they choose public it will default back to "Friends" since that is what was picked when they connected through my app initially.
I have found examples of accessing the permissions in the privacy_setting table using FQL but not for a particular app (also that looks to be going away with versions after 2.0 according to https://developers.facebook.com/docs/reference/fql/privacy_setting/.
I have not been able to find an end point in the Graph Api to provide the apps privacy setting for a given app.
Would appreciate if anyone knows how to get this.

How to get Facebook photo privacy settings via GRAPH API

There is no mention of privacy for Photo object,-
https://developers.facebook.com/docs/reference/api/photo/
But its possible to get/set the same for each photo via FB website. So is it possible using GRAPH/FQL to get/set privacy settings for Photo?
For getting the value: see Lix's response.
For setting the value:
Without the column exposed via the API, it's not going to be possible to change/update its privacy. I can see this being a great bug for you to log at http://developers.facebook.com/bugs
Aside from two special albums, namely "mobile uploads" and "wall photos", photo privacy is governed by the album (same on Facebook web too so the bug request won't help here). If you post to me/photos then you are posting to an album auto created for your app. You can post to any album by posting to albumid/photos.
The good news is that you can set the album privacy for an album that you create via the Graph API. See the "albums" section on this page.

Facebook Photo ID

Does the Facebook API return the UNIQUE ID of photos I upload to FB through my app?
There are data I would like to keep track of of the photos which Facebook doesn't but I want to present in my app.
Thanks
Each photo was specified with a unique "identity", This identity is specified by the user's id and photo's id
A typical url of a photo looks like this:
http://www.facebook.com/photo.php?fbid=xxxxxxxx&set=a.xxxxxx.xxxxx.xxxxxxxx&type=3
That's a preview mode, in order to access a user's photos you must have also the privileges to access it
Also I know that each photo on fb has a permalink too
Looking like :http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/xxxx_10150317692149803_5524802_7778361_2055733189_n.jpg This is also accessible though fb's sdk but also is under user's privileges
I believe it does, but you will most likely need the correct photo privilege to retrieve it. Also if your app is posting the photo. It should return the id of the newly created picture
https://developers.facebook.com/blog/post/498/
Yes you can do it. When your application uploads any photo of facebook, facebook creates a album with your application name. Now you can grab all photos which have aid of your application. For more you can check from here
Yes, the id is unique. An id also tells us the type of object based on where it is within our global block of ids (FBIDs).

Privacy setting to enable online_presence?

We're developing an application which need to get user's friends' online presence. I'm already getting everybody's presence but some of them returns null value. I googled it and some say that it's a privacy setting for each user.
I looked at my facebook test account's privacy settings and the only content is this:
Your status, photos, and posts
Bio and favorite quotations
Family and relationships
Photos and videos you're tagged in
Religious and political views
Birthday
Permission to comment on your posts
Places you check in to
Contact information
Everything is set to public for everybody but then I still its online_presence returns NULL value. Where can I find that setting to enable online_presence permission? Thanks!
If you are using FQL, then the required permissions are 'user_online_presence', 'friends_online_presence'. Alternatively, with XMPP, it is 'xmpp_login'.

Caching facebook profile pics?

I'm building a site that allows users to sign in using their facebook account.
I want to cache nice big versions of the users profile pictures. I know that i'm not allowed to cache images for more than 24 hours so i'm going to re-fetch the images once every 24h.
I thought i could get the url of the image original like this:
$fb=new Facebook($key,$secret);
$query = "SELECT src_big FROM photo WHERE pid IN (SELECT cover_pid FROM album WHERE owner = ".$id." AND name = 'Profile Pictures')";
$imgurl = $fb->api_client->fql_query($query);
http://wiki.developers.facebook.com/index.php/Photo_(FQL)
But i get an exception saying "Requires user session". Why do i need a user session? Is there a workaround for this? How does other sites solve this?
If i have a user session it works for some users but not all. Why not?
Rules on photo accessibility are detailed with the Photos.get API method.
Privacy Note: Photos are visible on
the Facebook Platform only if the
photo owner has authorized the calling
application, or the photo owner has
not turned off access to the Platform.
The Photos.get method is essentialy a wrapper for querying the Photo FQL table so it follows the same rules.
Consider asking users for the offline_access extended permission so you can query their own photos even when they're not online. You'll need to store their session key in your database and make queries with that, but it will mean you can pull down the photos of users who have authorised your application whenever you want.
For when it sporadically works: Some users may have set privacy settings to disallow applications access to their profile pics.
Possibly some users might not have uploaded a profile pic.
Edit: From the (new)fb menus go to: Account > Privacy Settings > Applications and Websites > What you Share
(This page explains about how the user's privacy setting choices affect fb-enhanced websites)
In short the external website can only access what fb users have made available to 'Everyone'.