Search code examples
facebookfacebook-graph-apikoala-gem

Facebook Graph API version change - can't retrieve posts


Since Facebook's Graph API changed to version 2.4, I find that any query attempting to retrieve posts made returns an error:

    type: OAuthException, code: 1, message: An unknown error has occurred. [HTTP 500]

My request code uses Facebook's koala ruby api to make requests:

     posts = @graph.get_object(appid+"/posts?limit=20",api_version: "v2.3")

I added the version count now, based on koala's recommendation, but the result for this is still the same error that I got without specifying the version. My access token is definitely valid, does anyone know if something else has changed or if this is a bug?


Solution

  • Extending @Tobi 's comment. You have to pass a page/event/user/group id to retrieve the post.

    Also, you've to explicitly pass fields parameter to query additional data of a post. So your query will become:

    posts = @graph.get_object(id+"/posts?fields=id,name,message,picture&limit=20",api_version: "v2.4")
    

    Please refer to this document of Facebook Developers to learn more about /postsedge.