Displaying Content to App Users
Problem
How do I display content only to users who have added my app or accepted the Terms of Service for my application?
Solution
Facebook used to offer two tags that provided an easy way to
limit the visibility of content, but only one is still supported. The
fb:if-user-has-added-app
tag, which is now deprecated, worked for all users who had
added your app. The fb:if-is-app-user
tag, which you should now always use, limits the display to
users who have explicitly
accepted your Terms of Service. The simplest use case is:
<fb:if-is-app-user>Thanks for installing my application! You rock!</fb:if-is-app-user>
Discussion
With no uid
specified, the
tag will automatically assume that it’s for the current loggedinuser
. You can
specify a uid
to check for a
different user, as well as include the fb:else
tag to provide alternate content:
<fb:if-is-app-user uid="12345"> Here's <fb:name uid="12345" possessive="true" /> score: 55555! <fb:else> <fb:name uid="12345" /> hasn't signed up for this app! </fb:else> </fb:if-is-app-user>
Note that these tags can be used only in a Canvas page.
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.