Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用Github API和Octokit获取用户事件_Ruby On Rails_Github_Github Api_Octokit - Fatal编程技术网

Ruby on rails 使用Github API和Octokit获取用户事件

Ruby on rails 使用Github API和Octokit获取用户事件,ruby-on-rails,github,github-api,octokit,Ruby On Rails,Github,Github Api,Octokit,我试图通过octokit在github上进行一个简单的调用来检索用户事件 根据这些文档,我创建了新的客户端并访问了用户事件端点 client = Octokit::Client.new(access_token: my_token) user = client.user 到目前为止,一切正常,现在我继续 events = user.events => nil 或者,当我这样做的时候 client = Octokit::Client.new(access_token: my_token,

我试图通过octokit在github上进行一个简单的调用来检索用户事件

根据这些文档,我创建了新的客户端并访问了用户事件端点

client = Octokit::Client.new(access_token: my_token)
user = client.user
到目前为止,一切正常,现在我继续

events = user.events
=> nil
或者,当我这样做的时候

client = Octokit::Client.new(access_token: my_token, api_endpoint: 'users/:user/events')
我明白了

#您有一个输入错误:

client = Octokit::Client::new(access_token: my_token)
                        ^^
应该是:

client = Octokit::Client.new(access_token: my_token)
                        ^

我想你想要的是

client = Octokit::Client.new(access_token: my_token)
user = client.user
events = client.user_events user.login

这不是很直观,我不得不读这本书。我还没有机会测试这一点,但似乎没有更好的方法。

正确,但这是一个打字错误。我能够连接但无法检索我正在查找的数据。有什么想法吗?非常感谢,你很接近。下面是如何检索events
events=client.user\u events(user.login)
@olivier请随意编辑我的答案,然后:D撇开这一点,我觉得这可能是个bug。我以为octokit接受对象和字符串,但我可能错了。@olivier很抱歉他们拒绝了你的编辑。如果我在网上看到它,我会接受它的。
client = Octokit::Client.new(access_token: my_token)
user = client.user
events = client.user_events user.login