I am able to post to one of my own pages in Facebook using the Facebook SDK and Winforms and C#. However, when I post the photo or message or whatever, it shows that the item was posted by "Jim Tyminski" and not the page name "ListWithFreedom.com". How do I get the post to show that it came from the group and not my personal ID?
That is not even possible directly in the group, without the API. You can only post as a page (with the correct permissions and Access Token) or as a User (with the User Access Token).
Edit: Posting to a Page as the Page is possible, of course, you just need a Page Access Token instead of the User Access Token. That´s the only Token where you actually have to deal with Tokens, usually the handling is done by the SDKs out there.
Some useful Links:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/
In general, you have to authorize the User with the "manage_pages" permission, and make an API call to "/me/accounts" to get the Page Access Token for your specific Page. With that Token, you can post as the Page.
Related
I start to working with the Facebook graph API and I have question:
I make Facebook Authentication, so after user approve my application I got accessToken and the facebookUserID. note: The accessToken is expire after One hour(!!!).
Then, in another webpage "index.html", I want to show all the users who approved the application with their full name and profile picture taken from Facebook.
Now I don't understand.. if someone will enter the "index.html" page to see list of users who accepted the application - 5(!!) month after their authentication, when i will make the HTTP call to get thier fullname and profile picture, the accessToken is now expire(a lot time before) so the HTTP call will not succeed.
The last option is to save the full name just in the One hour between user accept the application and before the accesstoken expiration. but if the user will change his name sometime... I don't have the updated Name!
if its important - I'm usind the javascriptSDK with asp.net project.
Please help me to understand how to solve this situation.
It would appear that it is not possible to generate a long-lived token with the JS SDK directly, you will have to involve the server side, see this page for details.
I want my facebook application to create events in my facebook page. Everyone that use my application will be able to publish events to my facebook page, so I don't want to give admin or contributor to everyone, I want my web app ( appId + secret code) to have the rights to publish
When I'm trying this:
client.AccessToken = "{app-id}|{app-secret}";
dynamic result = client.Post("/{page-id}/events", new{
name = "testEvent",
start_time = "2014-04-11T19:00:00-0700",
end_time = "2014-04-11T20:00:00-0700",
}
);
I received this error
{
"error": {
"type": "Exception",
"message": "You must be an admin of the specified page to perform the requested action.",
"code": 1373019
}
}
Any idea?
You should do the following:
Get a Page Access Token via the /me/accounts endpoint (the logged
in User must be the administrator of this page). You can do this via
https://developers.facebook.com/tools/explorer?method=GET&path=me%2Faccounts Be sure that you have requested the manage_pages, create_event and publish_stream permissions beforehand.
Exchange your short-lived Page Access Token to a non-expiring one as described here:
What are the Steps to getting a Long Lasting Token For Posting To a Facebook Fan Page from a Server
Use the newly generated Page Access Token in your App
The token that you are using is called the App Access Token, and according to the documentation of /{page-id}/events, it says:
An page access token for the page with create_event permission is required.
Now to get the page access token-
First you need to re-authenticate the user (by calling the facebook login/auth again) by adding the permissions:
manage_pages, required for getting the page access token
create_event, required for creating an event
Then make the call:
\GET /{page-id}?fields=access_token, you will get the page access token in response.
Use the token generated in step-2 and make the call you are making, then it will be a success.
(If required, you can also extend this page access token that will never expire- see here)
Learn more about access tokens here.
I am getting different results from different pages in Facebook. I am using the FacebookClient api to pull data from "https://www.facebook.com/PAGE". From that I parse out the ID and create a new URL to pull feeds. For example, https://graph.facebook.com/PAGEID/feed?access_token=xxx.
But my first call is failing when I try to get the page data from https://www.facebook.com/capncrunch and ONLY that page. It doesn't return me the page id like in other page requests I do.
Oddly I am able to get data via the Graph API explorer but not via the FacebookClient api. What I am doing wrong?
You access token is APP ACCESS TOKEN, and the page capncrunch is user restricted. You must use USER ACCESS TOKEN to verify the user is full fill(minimum age, country...etc) the requirement.
Visit
Use Facebook app access_token to get age-restricted Page data through Graph API?
https://developers.facebook.com/docs/opengraph/howtos/user-restrictions/
https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/
for more info
I have exactly the same problem as Marco here: c# Facebook SDK, get token to write to my Page Wall , got to the same point as Marco (obtaining token manually and storing in web.config.
Problem I have is that this token is set to expire, so it cannot be really used as config value in my web application.
Is there a way in Facebook c# SDK to obtain this type of token?
Please note that as a page admin, I've already granted my FCBK app manage_pages permission (which does not seem to expire) so there should not be any human interaction necessary when obtaining this type of token.
Thanks, Antonin
EDIT
seems like running this request: https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&redirect_uri=<URI>&scope=manage_pages,publish_stream,offline_access&response_type=token might be what I'm looking for, non-expiring access token. Pay special attention to values for scope parameter, especially offline_access.
I thought I had read somewhere that the page access tokens were temporary even when asking for offline_access. But that's really not an issue because you can use the user's permanent token to call me/accounts to get the list of apps and grab a token from there.
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?
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.