WordPress database error: [Got error 28 from table handler]
SELECT DISTINCT ID, category_id, cat_name, category_nicename, category_description, category_parent FROM wp_str8_categories, wp_str8_post2cat, wp_str8_posts WHERE category_id = cat_ID AND post_id = ID AND post_id IN (5426)

WordPress database error: [Can't open file: 'wp_str8_comments.MYI'. (errno: 145)]
SELECT ID, COUNT( comment_ID ) AS ccount FROM wp_str8_posts LEFT JOIN wp_str8_comments ON ( comment_post_ID = ID AND comment_approved = '1') WHERE post_status = 'publish' AND ID IN (5426) GROUP BY ID

STR8BLOGGIN » Blog Archive » How to determine who installed your Facebook app in a tab

How to determine who installed your Facebook app in a tab

As any Facebook developer knows, Facebook has some restrictive ideas about permissions and what apps should be allowed to do on your behalf or even know about you. One consequence of this is that Facebook avoids giving you any information about the user who is interacting with your app in a tab. The session data you are given will contain the page’s id (known as profile_id in the decoded signed_request value) but not the user’s id. The user’s id is available when people interact with your app outside of a page tab, but that doesn’t help when it’s in a tab.

Aside: New developers, always remember that Facebook gives you more or less access to the platform depending on how the app is being used. If your code doesn’t seem to work when running in a tab, try running it directly through the canvas at http://apps.facebook.com/[app-name]/. If it works there, you probably have some permissions weirdness going on.

So, how do you determine the user id of the person who installed your Facebook app as a tab on their fan page?

There are three ways to do this that I’m aware of. If I missed anything, let me know.

  1. Some confusing combination of access permissions, session keys, and page.info and page.isAdmin. I have no idea how to get this working reliably from a tab without requesting extended permissions. If anyone does, please give me a specific example.
  2. Maintain a table of installed app state, called something like app_installs. In there, track page ids that have installed the app, saving all the information you can find about them. Create a setup or edit page, and put that in the Edit URL field of your Application Settings. When your app is loaded, check that app_installs table to see if a record already exists for the page id (profile_id in signed_request). If it doesn’t, instruct the user to click the Edit Page link, then find your app and click Edit. Your app will run in canvas, as the user who admins the page, with both the profile_id and user_id variables available to you! Store this information, update the app_installs table, and you’re good to go! This might also be a good place to do some queries against the page and user FQL tables and store the information in your local table.
  3. Basically the same as above, but use an <fb:visible-to-owner>>a href="[encoded_secure_edit_url]">Click here to finish setting up the app</a></fb:visible-to-owner> construct to build a secure edit URL (perhaps based on a session key or md5'd profile_id/APP_SECRET combination). Facebook will only show this link to the page admins, and then you will be able to get the rest of the user information after the click.

Hope this helps some struggling Facebook App developers!

WordPress database error: [Can't open file: 'wp_str8_comments.MYI'. (errno: 145)]
SELECT * FROM wp_str8_comments WHERE comment_post_ID = '5426' AND comment_approved = '1' ORDER BY comment_date

Leave a Reply