5

For "users" on Facebook, I gather 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:)

jBit
  • 2,971
  • 1
  • 24
  • 39
wakurth
  • 1,644
  • 1
  • 23
  • 39
  • Is your application inside a page tab? – ifaour Aug 18 '11 at 17:48
  • possible duplicate of [How can I find out what Page has installed my Facebook Canvas App?](http://stackoverflow.com/questions/5587784/how-can-i-find-out-what-page-has-installed-my-facebook-canvas-app) – ifaour Aug 18 '11 at 19:00
  • no, my application is a SAAS hosted site for compliance and archival. – wakurth Aug 18 '11 at 19:22
  • You can follow the details steps as explained here - https://stackoverflow.com/a/76329303/12326605 – Arpit Jain Aug 06 '23 at 06:57

3 Answers3

2

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.

wakurth
  • 1,644
  • 1
  • 23
  • 39
1

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/

Einacio
  • 3,502
  • 1
  • 17
  • 21
1

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.

jBit
  • 2,971
  • 1
  • 24
  • 39
  • I think my question was not read correctly. For users, I can get their Facebook userID immediately after the authorize my application via their access token. If my application is approved for a "page" and not a user, and the page has no "user" account attached to it, I can't get the PageID through any method I know, and they only pass back a "access_token" and "code" query string parameter. if the "code" parameter can be decoded to get info like this, then I will use that, I just wasn't aware of that being possible.. please let me know if my question make more sense now. – wakurth Aug 18 '11 at 19:14
  • Only users can authorise applications. Application tabs can only be installed on pages. The only way to get the pages id is through the signed_request that is passed to the tab iFrame installed on said page. – jBit Aug 18 '11 at 19:18
  • I have no iframe on my page. I redirect them to the "allow" page in a new tab on Facebook, and when the click allow, it redirect to a page that handles gathering their information. In this situation, there is no user involved. Its just the login of the page with no users attached to manage it. The email they use to login in not actually attached to a user Facebook account. So the "page" is actually authorizing my application. – wakurth Aug 18 '11 at 19:28
  • Since there's no userID to work from in using FQL to get page ID's and there's not info in the signed request... I don't believe it's possible for pages to utilize application outside the FB canvas that don't have a "user" attached to the page. – wakurth Aug 18 '11 at 19:29
  • An actual user is required to use a facebook application with authentication. Pages cannot use applications - they can only host tabs. Facebook applications can be used by anybody if no authentication is required. – jBit Aug 18 '11 at 19:37