tags:

views:

52

answers:

1

I want to post an event to a facebook "group" using the graph API from a php application running elsewhere. Basically when someone creates an event on my system I'd like to also publish it as an event in facebook in my group.

I created an application on facebook and then get an authorization token using the following URL :-

https://graph.facebook.com/oauth/access_token?client_id=XXXX&client_secret=XXXX&type=client_cred

This gets me back a token I can use.

I then try to create my event like this -

https://graph.facebook.com/{GROUP_ID}/events?name=Test%20event&start_time=$st&end_time=$et&access_token=$oauth&privacy=OPEN&page_id={GROUP_ID}

$st and $et are php variables containing the event start and end times and $oauth contains my access token

But I get back a permissions error.

Clearly my access token for my application doesn't have permissions to post an event to my group. So.. Is there any way to give it those permissions? Or is there a different approach I need to use?

+2  A: 

You need to request the permissions when you login. For example (standard PHP SDK for Facebook):

$loginUrl = $facebook->getLoginUrl( array('req_perms' => 'publish_stream,create_event,offline_access,manage_pages') );

Where 'create_event' would of course give you permissions to create new events.

Prot0
Do you know if I can do this using the graph API? And if I can do it when getting a logon as an application rather than a user?
John Burton
What do you use to authenticate/get your access token?
Prot0
The first URL in my post (But with the applications ID and secret obviously). I get back a token which works ok for some other calls, it just doesn't have permission to post an event to my group.
John Burton
Prot0
Thank you. The facebook documentation is ok once you know where to look, but it's really hard to find things when you don't quite know what you need to know :)
John Burton
You're welcome. Very true :-) Took me some time to find what I needed, and how to use it (also since I used the PHP SDK for my project).
Prot0
I actually found a blog post http://www.typeoneerror.com/blog/post/permanent-facebook-sessions-and-posting-as-a-page which together with this post has let me get it working,
John Burton

related questions