Check if page tab app is still installed

[亡魂溺海] 提交于 2019-12-22 04:43:17

问题


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


回答1:


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!



来源:https://stackoverflow.com/questions/8198530/check-if-page-tab-app-is-still-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!