How to post on facebook page as that page - facebook

Let's say I've create a facebook page named MyPage.
When I am using a web interface of FB, I can either post on that wall as the user I am logged in as (personal user) or as a page instance, MyPage user.
Is it possible, via any of the available API's, to post on a facebook page as that page's user programmtically from my desktop application code?

To post on facebook page as that page, you need an page access token of that page.
To get the page access token, you need-
permission: manage_pages.
API call: /{page-id}?fields=access token
(If you are not aware, you can test the graph api calls from: Graph API Explorer)
In the posting code, just add a parameter: access_token and give it the page access token. That's it.
PS if you wish to extend this token, that'll never expire, you can get the login from here: What are the Steps to getting a Long Lasting Token For Posting To a Facebook Fan Page from a Server

Related

Posting to a Facebook Page Wall from a Web Server

I've been reading documentation and Stack Overflow link all morning, but I'm just not understanding the correct process to authorize a web server to post to a Facebook page wall.
What I'm not clear on is why I have to post to Facebook as a Facebook User, using an access_token, meaning that this user has to log into Facebook manually to authorize my app.
I'm not trying to authorize a User, nor any of my visitors to do anything with their accounts, so I don't need any permissions from them. Instead, I'm trying to authorize my Web Server to post updates to its wall as a specific Page.
Why do I have to use a user access_token to do this? I'm not attempting to impersonate the user, I'm trying to post to the page as the page...
Is it possible to authorize a user and get their access token without having to create a login page on the Web Server? I don't want to have to require the user to login to make this work, I thought that was the point of having an app ID and Secret?
I guess my question is this: Is it not possible to allow a web server to post to a Facebook page wall as that page, without having to present a login dialog to a specific user? If it is possible, what is the correct workflow to set this up?
In order to post to a Page as a Page, you have to use a Page Access Token. You get that with a User Access Token, and you can extend it so it will stay valid forever.
Steps:
Request a User Access Token with the manage_pages permission (valid for up to 2 hours)
Extend the User Access Token (valid for up to 60 days)
Get the Extended Page Access Token for your Page with the User Session
Store and User The Page Access Token in the publish call
It may sound a bit complicated, but there are many tutorials for this and you don´t actually need to program it, you can just use the Graph API Explorer.
Here are some Links about the Access Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/ (see "Extended Page Access Token" for a step by step tutorial)

automatically posting on facebook with pagetab app

i have a facebook pagetab app this app is installted on pages where i'm not the admin.
Can i post on this pages with the app by using the facebook api.
Sorry for my bad english and thx for answers!
Since you are not the admin of the page, you can't publish to their page using your app! Since, to publish new posts on behalf of tat page, a page access token with publish_actions permission is required. (see more on this here)
And to generate a page access token, an admin of the page must grant an extended permission called manage_pages. Once this permission has been granted, you can retrieve the page access token using the following Graph API request:
GET /{user-id}/accounts
So only the admin could generate the page access token, and if you have that (of course with his perms :P), you can post on that page on its behalf!

Getting page access_token for a Facebook page (using Graph API)

I am trying to access a public FB community page and display the images on web page, example-http://www.codeofaninja.com/2011/06/display-facebook-photos-to-your-website.html
My site is being developed in java, so I am looking for a core java solution to do something like this.
My site does not prompt for the user to login via Facebook or authenticate. I am simply trying to display all the images from my own album on my website.
I have created an FB app, and then created a community page on which I have my pictures.
I am struggling to I authenticate from the backend code of my with my app or page. My app has user_photos permission and the App Type (Apps->Your APP->Advanced->App type) is Web.
Here are the things I tried using graph API:
1) Get access token
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
2) Then use access token to get access to the page and its albums, but the above gives me app access_token. As mentioned on Graph API documentation for Page it requires a page acess_token, but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
After Page access token is retrieved I can use the following call to retrieve all photos.
https://graph.facebook.com/PAGE_ID/photos?access_token=<page_access_token>
You can make the following Graph API call To get the page access tokens for all the Pages a particular user admin.
https://graph.facebook.com/user_id/accounts?access_token=<user_acess_token>
the app access token that you're retrieving from
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
can be used to access the public data on a page - you don't need a specific 'page' access token.
this page https://developers.facebook.com/tools/explorer/ is handy for testing things out - plug in the app access token and the page url to try it out
but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
Not at all …
To get a page access token, you have to have a user access token with manage_pages permission first.
(If you get a long-lived user access token, and use that to get the page access token, then the latter will not expire by default.)

How do I get an auth token for a facebook page if my app has been added to it?

My app's only purpose is to make posts as Facebook pages, so we'd like to take user login out of the flow.
If the user adds our app to their page using a link like http://facebook.com/add.php?api_key=APP_KEY&pages=1, how would I get an access token to make posts as that page?
Thanks :)
At least one of the page's admins has to authorize your app with both manage_pages and publish_stream permissions. (see https://developers.facebook.com/docs/reference/api/permissions/)
Then once you get their access token, call the graph with me/accounts and in that list will be the page. (see the Page Login section of https://developers.facebook.com/docs/authentication/) In there will be a page access token for managing that page. So then you can HTTP Post to me/feed a new message using that page access token.
Happy coding!

How to post a comment on Facebook Page as User, not as Page

I want to post a comment on Facebook Page as User.
The user is admin of the facebook page.
I tried that my app requests the following URL with the user's access token.
https://graph.facebook.com/[POST_ID]/comments
But the comment was posted as Page account.
I was able to post on Facebook Page as User.
My app requests the following URL with the user's access token.
https://graph.facebook.com/[PAGE_ID]/feed
It's successful.
With the pages's token, the post was successfully posted as Page account.
But comment and like can't be posted as User.
Is it a bug of graph API? Please help me.
If you post with the User's Access Token it will show up as being from the user. It will only show up as being posted by the page if you use the Page's Access Token obtained from me/accounts/ in the GraphAPI.