English 中文(简体)
我要获得用户访问代号,而不是应用程序访问代号
原标题:I want to get user access token rather than application access token
  • 时间:2012-05-25 06:07:51
  •  标签:
  • facebook

我想得到用户访问标记, 因为我需要获得用户的留言和评论。

当我使用图形 API 探索器时, 它生成的访问符号是正确的, 并显示我的文章、 评论和其他数据。 但是, 当我试图通过使用此代码来获取文章和评论时, 它不会回复我的文章和评论, 也不会回复一些我不需要的其他数据 。

 require_once( facebook.php );

 $config = array(
     appId  =>  383128895071077 ,
     secret  =>  6a9ab479186f53db5c531a3fa5f91be0 ,
 );

$facebook = new Facebook($config);
$access_token = $facebook->getAccessToken();
$result = $facebook->api( /me/feed/ , array( access_token  => $access_token));

I searched all the google and get access token by different ways but I could not get posts and comments of me. I must be doing something wrong and need to sort out this as soon as possible. Thanks in advance.

问题回答

You should check this example Facebook php sdk example

您应该检查我们是否有像这样的用户访问标记

   // Get User ID
    $user = $facebook->getUser();

    // We may or may not have this data based on whether the user is logged in.
    //
    // If we have a $user id here, it means we know the user is logged into
    // Facebook, but we don t know if the access token is valid. An access
    // token is invalid if the user logged out of Facebook.

    if ($user) {
  try {
    // Proceed knowing you have a logged in user who s authenticated.
    $user_profile = $facebook->api( /me );
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}

一旦我们获得用户细节, 您可以确保用户被登录到应用程序中, 并授权应用程序 。

For feeds
You should have extended permissions read_stream

然后,你可以读取墙壁的种子。





相关问题
Facebook Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签