Search code examples
c#facebookfacebook-wall

Post on a Facebook business page from another user app


I created a company page.

After creating a company page I created an administrator user for it.

I have a FB application that posts on another users wall using their user id (stream.publish).

I want to post on the company wall too, but how can I post on the company wall if I don't have its userID, or appID.

When I use the company page, I don't see details about it in the settings or any other configuration page.

How can I get the company page userID/companyID/accesstokenID, so I can post on its wall?


Solution

  • You need to request the manage_pages permission, for the admin user you assigned to the pages. When you return from the authorize URL, where you get the user's access token, you need to call the https://graph.facebook.com/me/accounts?access_token=TOKEN_FROM_ABOVE URL, which will give you a collection of pages, each with its own access token.

    When you use that access token for publishing, it should publish as the Page.

    http://developers.facebook.com/docs/authentication/ - Check the Page Login section.

    UPDATE

    This is the URL, you redirect the browser to:

    https://graph.facebook.com/oauth/authorize?client_id=APP_ID&scope=manage_pages,offline_access&display=Popup&redirect_uri=REDIRECT_URL
    

    When the user returns to the specified Redirect URL, you grab the value in the code URL parameter and call the Facebook API to exchange it for an access token. All this, you've probably already done, since you have an application that posts on a user's wall.

    What you'll do now, using the access token, is call https://graph.facebook.com/me/accounts?access_token=TOKEN_FROM_ABOVE which will give you the collection of pages the authenticated user manages, and each one have its own access token.

    Grab the desired access token, and use that to post on the pages wall.