tvishwa107
tvishwa107

Reputation: 311

Koala - likes edge responds in graph API explorer but not to koala code

I've written some code in Ruby using the koala library. What I'm trying to to do is get a few page edges like so:

     line = 110360775652715
     x = line.to_s+"/posts"
     posts = @graph.get_objects(x)

When I use my code to run this, I get the following error merrage:

    Error: type: OAuthException, code: 803, message: (#803) Some of the aliases you requested do not exist: 110360775652715/posts [HTTP 404]     

However, when I feed

    110360775652715/posts

directly into the graph API explorer developer tool, I get a proper response. My access token is fine, it's not expired or anything.

What gives?

Edit: I know my question talks about the 'likes' edge but I have the same issue for 'posts' as well, so I figured it doesn't matter.

Upvotes: 0

Views: 98

Answers (2)

tvishwa107
tvishwa107

Reputation: 311

This was just carelessness. I've been sending the

   get_objects      

call which is for multiple objects instead of

   get_object

which is more suitable since I have only one object.

Upvotes: 0

phwd
phwd

Reputation: 19995

The correct call is @graph.get_connections

For example @graph.get_connections('boo','posts')

That get_objects is for requesting multiple objects in one call https://github.com/arsduo/koala/blob/ffa1dc61cf06a5c875567c1442db04956754b811/lib/koala/api/graph_api.rb#L69

ids = ['boo','4']
profile = @graph.get_objects(ids)

With the response as

=> {
    "4" => {
        "id" => "4", "first_name" => "Mark", "last_name" => "Zuckerberg", "link" => "https://www.facebook.com/app_scoped_user_id/4/", "name" => "Mark Zuckerberg", "updated_time" => "2015-12-02T02:25:29+0000"
    }, "boo" => {
        "id" => "80329313253", "about" => "My name is Boo. I am a dog. Life is good.", "affiliation" => "Dog", "birthday" => "03/16/2006", "can_post" => false, "category" => "Public Figure", "checkins" => 0, "cover" => {
            "cover_id" => "10153114279788254", "offset_x" => 0, "offset_y" => 0, "source" => "https://scontent.xx.fbcdn.net/hphotos-ash2/t31.0-8/s720x720/10633949_10153114279788254_8392027345261588939_o.jpg", "id" => "10153114279788254"
        }, "has_added_app" => false, "is_community_page" => false, "is_published" => true, "likes" => 17345372, "link" => "https://www.facebook.com/Boo/", "name" => "Boo", "parking" => {
            "lot" => 0, "street" => 0, "valet" => 0
        }, "personal_info" => "Boo the World's Cutest Dog\nInstagram: @buddyboowaggytails\nTwitter: @buddyANDboo", "personal_interests" => "Favorite foods:  chicken, cheese, flowers, grass, dirt ...\n\nFavorite games: running outside, following around big bro, squeaky toys!\n\nFavorite pastime: wearing shirts\n\nFavorite color: pink\n", "talking_about_count" => 401445, "username" => "Boo", "website" => "http://www.facebook.com/Boo", "were_here_count" => 0
    }
}

Additionally the ID you are requesting is for a merged wiki page, so you will not get the same data as a normal page.

https://www.facebook.com/pages/Cheating-in-video-games/108346199186173?rf=110360775652715

Upvotes: 1

Related Questions