问题
Facebook Page Tab Problem
Well, I don't know how to say this, I want to retrieve the user's id and user's name on the page tab of facebook.

Then when you clicked the Application where the arrow points it should look like this.

I don't get it why the Page Admin and Page Like is 1 it should output the ID of the users right? and why the UserID is 0? I logged on and I already liked the page
Then I wanted to retrieve the user's name and user's id "to the user" who will use this page tab app thing.
Here is my code for that.
if(!@include("../sdk/facebook.php")) throw new Exception("Failed to include 'facebook.php'");
$app_id = "xxx"; // Your application id
$app_secret = "xxx"; // Your application secret
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signedrequest = $facebook->getSignedRequest();
$fbp_id = $signedrequest["page"]["id"]; //Facebook Fan Page ID
echo $is_admin = $signedrequest["page"]["admin"]; echo " Page Admin <br>";
echo $is_liked = $signedrequest["page"]["liked"]; echo " Page Liked<br>";
echo $uid=$facebook->getUser(); echo " User ID<br>";
Well I can retrieve the Fan Page ID, using the $fbp_id still, I can't retrieve the user's id it only outputs 0. How can I retrieve it? Any solution for this?
Would be glad if you help me.
回答1:
First of all You must take a permission from your user to get his/her data. There are two ways you can do that the best way will be
$loginUrl = $facebook->getLoginUrl(
array(
'redirect_uri' => $your_page_tab_url,
'scope' => 'email'
)
After getting this url check if the user_id is 0 than redirect him to
<script type='text/javascript'>top.location.href = '$loginUrl';</script>
but one more thing this is for the new PHP sdk so you will have to update the one you have
来源:https://stackoverflow.com/questions/14930648/facebook-php-sdk-facebook-getsignedrequest-get-user-id-and-name-page-tab