开发者

Facebook Graph api How to get page ID via an access token

For "users" on Facebook, I gathe开发者_开发知识库r information like their user ID by using this graph api call: https://graph.facebook.com/me?access_token=... This works every time.

My question is... is there a way to get the page information about the page that was just authorized via the access token that is returned after authorization?

I tried this, and id doesn't work, but this is what I'm looking for

https://graph.facebook.com/page?access_token=...

As you know, in order to post to a "page" wall is to 'Post' like so... https://graph.facebook.com/PAGEID/feed?message=blahblah&access_token=XXXXXXXXXXXXX

How do I get the page ID and other info about the page that was authorized without already knowing the ID or page "username" (which you have to have 25 likes to use anyway)???

Thank you for any help stackoverflow community:)


The answer I was looking for is here. You can simply use a users access_token to get a set of their page_access_tokens, and give them the option of posting to these pages using these access tokens based on the return JSON object data.


pages are not authorized, applications are.

in case that your application has permissions, the current page is informed thru the signed_request that FB passes to the app canvas. use the php sdk to read it

https://developers.facebook.com/docs/authentication/signed_request/


There's no callback when an application is installed on a page. However, if a user is using your application via a tab iFrame you can get that pages id from the signed_request. You could maintain this information as part of your own user session, and use it as you see fit.

The contents of a signed_request to a tab iFrame would be similar to the following (output of PHP print_r):

stdClass Object
(
    [algorithm] => HMAC-SHA256
    [issued_at] => xxxxxxxxxx
    [page] => stdClass Object
        (
            [id] => FAN_PAGE_ID // target page id
            [liked] => 1        // is the user a fan
            [admin] =>          // is the user an admin
        )

    [user] => stdClass Object
        (
            [country] => ie
            [locale] => en_GB
            [age] => stdClass Object
                (
                    [min] => 21
                )

        )

)

For more information see: http://developers.facebook.com/docs/authentication/signed_request/


You may also want to take a look at the manage_pages permission

Also, see here: http://developers.facebook.com/docs/reference/api/

Page Login

You can impersonate pages administrated by your users by requesting the manage_pages permission.

Once a user has granted your application the "manage_pages" permission, the "accounts" connection will yield an access_token property for every page administrated by the current user. These access_tokens can be used to make calls on behalf of a page. The permissions granted by a user to your application will now also be applicable to their pages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜