考拉 - 喜欢图API探测器中的边缘响应,但不喜欢考拉代码

时间:2015-12-28 16:54:32

标签: ruby facebook facebook-graph-api koala

我使用koala库在Ruby中编写了一些代码。我想要做的就是得到一些像这样的页面边缘:

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

当我使用我的代码运行时,我得到以下错误merrage:

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

然而,当我喂食

    110360775652715/posts

直接进入图形API资源管理器开发者工具,我得到了适当的响应。我的访问令牌很好,它没有过期或任何东西。

是什么给出了?

编辑:我知道我的问题是关于'喜欢'边缘,但我有同样的问题'帖子'同样,所以我认为这没关系。

2 个答案:

答案 0 :(得分:1)

正确的来电是@graph.get_connections

例如@graph.get_connections('boo','posts')

get_objects用于在一次通话中请求多个对象 https://github.com/arsduo/koala/blob/ffa1dc61cf06a5c875567c1442db04956754b811/lib/koala/api/graph_api.rb#L69

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

响应为

=> {
    "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
    }
}

此外,您要求的ID是针对合并的Wiki页面,因此您将无法获得与普通页面相同的数据。

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

答案 1 :(得分:0)

这只是粗心大意。我一直在发送

   get_objects      

调用哪个是多个对象而不是

   get_object

这更合适,因为我只有一个对象。