Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if page tab app is still installed

What is the best way to check if a tab app is still installed on a specific Fan Page, using the graph api?

The only way I can come up with is using, https://graph.facebook.com/page_id/tabs/app_id, and this will return the data for the given tab, if it is installed, but it appears a access_token is required. To use this method, I think, I would need to ask the user for not only the manage_pages permissions but also for the offline_access, then I could store the page_access_token and be able to use it later for sole purpose of checking if the app has been removed?

It seems odd that this wouldn't just be public information, considering without being logged into Facebook, you can see all the tabs installed on a fan page?

Here is a similar question asking about the Deauthorize Callback: http://facebook.stackoverflow.com/questions/8000163/deauthorize-page-tab-notification

Thanks

like image 864
Jackson Avatar asked Nov 20 '11 00:11

Jackson


1 Answers

From my testing and according to Facebook's documentation, you don't need a user's access token to check if an app is installed (although you can use it). I found it easier to login as your app. Here's facebook's link that shows you how. Look at the section called "App Login".

In short, you get an app access token with something like this in php:

$access_token = file_get_contents(https://graph.facebook.com/oauth/access_token? client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET& grant_type=client_credentials);

Then you can use that access token to get the data tab:

$app_check = json_decode(file_get_contents("https://graph.facebook.com/". FACEBOOK_PAGE_ID . "/tabs/" . YOUR_APP_ID . "?access_token=" . $access_token;));

As you can see, I json decoded the contents of that file and then do a check to see if that app id exists on the page.

if(!empty($app_check->data)){

echo "APP IS INSTALLED"; }else{ echo "APP IS NOT INSTALLED"; }

I hope that helps!

like image 72
fldsofglry Avatar answered Sep 28 '22 03:09

fldsofglry