Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API -> user/events returns empty array

Firstly, to explain the situation:

  • my app has been approved by App Review for user_events (screenshot below)
  • i am testing on the production app, with a real user account (testing with admin user returns false positives)
  • calling {user_id}/ works and returns the basic profile.
  • calling {user_id}/permissions works and returns the permissions (inc user_events, screenshot below)
  • calling {user_id}/events always 'works' but returns and empty array.

I have tried testing with 'me' instead of the logged in fb_user_id and get the same empty data result. If I test from my own admin testing account, the user_events data is always populated with data. I have tried with less/no parameters than the screenshot below, all work fine for test users but not for live users.

Many thanks for any help!

screenshots:

enter image description here

enter image description here

like image 422
Haroldo Avatar asked May 01 '19 08:05

Haroldo


1 Answers

Testing with another user

My app is in development mode. You can also easily create and use testing users, customize them to your needs and log in to the account, or you can add a real facebook user to your account and assign him the tester role.

enter image description here

I log in with Ellison Clinton and create an event

enter image description here

I can retrieve via api the /events

enter image description here

Then I switch the facebook app to production and delete the user from the test role

enter image description here

I can retrieve the user information

enter image description here

but I can not retrieve the previously created event

enter image description here

Completing the authorization process

Maybe you did not complete the review process for user_events?

You can access the data in development, but not in production. I also did not complete the review process, but I can access the user_events data.

"If your app is in dev mode you should be able to get page access tokens with any permission for anybody who has a role on your app. If you just want to manage posts on your own page or the pages of users who have roles on your app, you'll be able to do so in development mode without submitting for app review." - Response from Facebook Developer Support

You may need to perform the

also consider filing a bug and including the link here

How to debug Facebook Graphql

The only possible scenario is that the token you are using does not include the user_events permission.

A request to /users/events with token missing the user_events permission will return status 200 and data: [], no error messages in the response.

I tested this scenario on the Graphql Facebook Explorer and the request does not return an error message. A debug message is displayed in the Api explorer, but it is not explicitly included in the response.

enter image description here

I exported this request as curl and this is the result

~ $ curl -i -X GET  "https://graph.facebook.com/v3.3/10210855772523702/events?access_token=TOKEN"
HTTP/2 200 
content-type: application/json; charset=UTF-8
facebook-api-version: v3.3
x-fb-debug: h1WInt+yxtkm/1isTGfG2cd9JX8HAx5R5A9U/QC4k2lRrJ5mrKYaInR2Mm6XQ5UOrdSquAgWKnYj2jiTw6fwLQ==

{"data":[]}

You can retrieve the debug info passing the param debug=all in your /users/events request as in the curl example below:

~ $ curl -i -X GET  "https://graph.facebook.com/v3.3/10210855772523702/events?debug=all&access_token=TOKEN"
HTTP/2 200 
{"data":[],"__debug__":{"messages":[{"message":"The field 'events' is only accessible on the User object after the user grants the 'user_events' permission.","type":"warning"}]}}

My advice to you is to add the parameter ?debug=all to your request and include the result of the response in your question, so that we can assist you troubleshooting.

Below are the other test I performed with the Graphql Facebook Explorer and I was able to retrieve the events.


STEP 1. Head over to Facebook Graph API Explorer

enter image description here

STEP 2. Generate a Token

  1. get token -> get user access token and add the user_events permission

STEP 3. Run the queries

Use the endpoint /me?fields=id,name to retrieve your user-id and then:

  1. get /{user-id}
  2. get /{user-id}/permission
  3. get /{user-id/events

as you can see from the pictures below, /events returns data: [], while the /permissions endpoint includes the user_events permission.

My Facebook user did not join any event in the future. Creating an event and repeating the test returned some results.

The images below showcase my test cases

enter image description here

enter image description here

enter image description here

enter image description here

like image 172
Fabrizio Bertoglio Avatar answered Oct 28 '22 21:10

Fabrizio Bertoglio