Reputation: 472
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?
Upvotes: 0
Views: 269
Reputation: 31479
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
Upvotes: 1
Reputation: 20753
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 tokencreate_event
, required for creating an eventThen 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.
Upvotes: 0