Hiding Private Profile Content
Problem
Privacy is such an important concern on Facebook, and I want to make sure my application follows all of the rules and regulations so I respect my users and don’t get Terms of Service violations! How do I make sure I’m showing users only the Profile content from other users that they’re supposed to see?
Solution
The fb:if-can-see
tag gives you full control over whether to display one
user’s Profile content to another user. The simplest form is:
<fb:if-can-see uid="12345">You're allowed to see this</fb:if-can-see>
Discussion
The simplest case is probably not all that useful to you, since
you’re probably more interested in a specific part of the Profile
rather than the whole thing. Add a what
parameter and include any one of the
following: profile
, friends
, not_limited
, online
, statusupdates
, wall
, groups
, photosofme
, notes
, feed
, contact
, email
, aim
, cell
, phone
, mailbox
, address
, basic
, education
, professional
, personal
, seasonal
:
<fb:if-can-see uid="12345" what="friends"> You're allowed to see <fb:name uid="12345" possessive="true" /> friends <fb:else> You're not allowed to see them. </fb:else> </fb:if-can-see>
Note that you can’t chain the what
s together, so you’ll have to nest
fb:if-can-see
tags if you want to
check for more than one permission at a time:
<fb:if-can-see uid="12345" what="profile"> <fb:if-can-see uid="12345" what="friends"> You can see <fb:name uid="12345" possessive="true" /> profile and friends. </fb:if-can-see> </fb:if-can-see> ...
Get Facebook Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.