0

I thought it is easy thing to do, but seems that it is not. I have an Android app. User logs in into this App, using Facebook. I also have a Facebook page (besides Facebook app). So, I want to create an event on behalf of my page from my android app. Here is what I do:

Bundle params = new Bundle();
    params.putString("name", "name");
    params.putString("description", "descr");
    params.putString("location", "loc");
    params.putString("start_time", "properly_formatted_time");
new Request(
        Session.getActiveSession(),                              
        "/" + PAGE_ID + "/events?access_token=" + PAGE_ACCESS_TOKEN,
        params,
        HttpMethod.POST,
        new Request.Callback() {
            public void onCompleted(Response response) {
        }
    ).executeAsync();

I have generated long living token with all required permissions as described here: Long-lasting FB access-token for server to pull FB page info

If I try to create event, being logged in as myself (admin of a FB page and application), it works fine.

When I am using someone's account, who is not an admin, I am receiving following error:

{HttpStatus: 500, errorCode: 1373019, errorType: Exception, errorMessage: You must be an admin of the specified page to perform the requested action.}

So, how it is possible to fix this. I've googled around and found some similar questions, like How to post to a Facebook Page (how to get page access token + user access token), but those either have no correct answer, or are using "me/account" and then get access_token, which is not something I want to do.

Any help would be greatly appreciated.

Community
  • 1
  • 1
Alex K.
  • 3,294
  • 4
  • 29
  • 41

1 Answers1

0

There's no other way in my opinion than to get the Page Access Token via the /me/accounts (being logged in as admin of that page), and then store this Token in the app itself.

What I'm not really understanding is that (all) the users can then create an Event for your Page. Is that really what you want?

Tobi
  • 31,405
  • 8
  • 58
  • 90
  • Yes, I really want each user to be able to create an event for my page (because the page itself should be creating events). But I am not able to access my page token, using "me/accounts", if I log in as a different user then myself. – Alex K. Mar 31 '14 at 07:41
  • Yes, that's true, so you need to store the Page Access Token in your App – Tobi Mar 31 '14 at 08:17
  • I am storing it. As described in question, I have created long-lasting token, and PAGE_ACCESS_TOKEN constant in the code is this token. I can debug it and see, that it never expires and has all necessary permissions. But still, I am getting above-mentioned error. – Alex K. Mar 31 '14 at 08:41
  • 1
    Although I'm not experienced in the Android FB API, I guess that "Session.getActiveSession()" is the problem here. Can this be set to something else? – Tobi Mar 31 '14 at 14:35
  • OK, in FB itself it is not possible to create an event, if you are not page admin. So, I suspect It is not possible also via Graph API. Thnx for your time. – Alex K. Mar 31 '14 at 14:42
  • This is not true, see https://developers.facebook.com/docs/graph-api/reference/page/events#publish Try requesting the Page Access Token with create_event permission. – Tobi Mar 31 '14 at 14:44
  • You were right about `Session.getActiveSession()`. I've tried to create another session for my page token and it worked. Though, now I have a problem of switching between page and user sessions, but this is already another question. Thnx. – Alex K. Apr 01 '14 at 06:32