Gem Koala Facebook API get_object请求 [英] Gem Koala Facebook API get_object request

查看:72
本文介绍了Gem Koala Facebook API get_object请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Gem Koala Facebook API使用以下代码获取用户信息

I'm trying to get user's info via Gem Koala Facebook API with below code

@graph = Koala::Facebook::API.new(auth_hash.credentials.token) profile = @graph.get_object("me") user.update( url: auth_hash.extra.raw_info.id, email: auth_hash.extra.raw_info.email, friends: @graph.get_connections("me", "friends"), birthday: @graph.get_object("me", "birthday") )

@graph = Koala::Facebook::API.new(auth_hash.credentials.token) profile = @graph.get_object("me") user.update( url: auth_hash.extra.raw_info.id, email: auth_hash.extra.raw_info.email, friends: @graph.get_connections("me", "friends"), birthday: @graph.get_object("me", "birthday") )

friends: @graph.get_connections("me", "friends")可以很好地工作,我会得到一个朋友列表.

friends: @graph.get_connections("me", "friends") works perfectly fine, I will get a list of friends.

但是birthday: @graph.get_object("me", "birthday")会给我type: OAuthException, code: 2500, message: Unknown path components: /birthday [HTTP 400]

返回诸如likesphotos之类的数组的东西可以正常工作.

Things that returns arrays such as likes, photos works fine.

但是像last_namenamefirst_name这样的字符串也会给我同样的错误.

But strings such as last_name, name, first_name will give me the same error.

我该怎么做才能解决此问题?还有其他我可以输入的内容,而不仅仅是birthday

What can I do to fix this? Is there something else I can enter instead of just birthday

推荐答案

尽管没有很好地记录,但我阅读了gem的代码.

Although it is not very well documented, I read the code of the gem.

此处它说明了如何做您想做的事.

Here it explains how to do what you want.

您可以这样做:

Koala::Facebook::API.new(ACCESS_TOKEN).get_object(:me, { fields: [:birthday]})

这将返回生日和用户ID.

This will return the birthday and the id of the user.

这篇关于Gem Koala Facebook API get_object请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆