Is there a way to identify when a facebook application runs through a fanpage page
Lets assume I have created a facebook app.So all those who(Admin) have facebook fan pages can add my app into their fan page and run my app through their fan page.I need to identify when someone run my app through his fan page.
Just assume this is my index.php file//index.php
<?php
include_once "fbmain.php";//Here I do all facebook Authentication parts
?>
<html>
<body>
<form action="http://localhost/test/test.php" method="POST">
<input type="submit" value="Upload开发者_运维百科"/><br/>
</form>
</body>
</html>
When a user click the "Upload" button,'test.php' file is loaded.In 'test.php' file I want to display the id of the fan page,
//test.php
<?php
echo "Hello".$ID_OF_THE_FAN_PAGE;
?>
//output eg: Hello 228276387189141
Can anyone tell me is there a way to do this?(I am using graph api and php to develop this app)
When your app is running as a page tab, an encoded signed_request parameter is sent to your app, which includes details about the page the app is installed on
See the documentation here: https://developers.facebook.com/docs/authentication/signed_request/
There's an example of how to decode the request and obtain the relevant fields.
The 'page' field in the signed_request includes the page ID, whether the current user likes that page, and whether the current user is an admin of that page
精彩评论