使用Github API和Octokit获取用户事件 [英] Get user events with Github API and Octokit

查看:911
本文介绍了使用Github API和Octokit获取用户事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



根据文档,我创建了新的客户端并访问了用户事件终结点。
$ b

  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')

我得到

 #< Octokit :: Client:0x007f9a78ac04f8 ... 

但是如何从那里获取事件列表?
以下是官方文档 https ://developer.github.com/v3/activity/events/#list-events-performed-by-a-user

解决方案

我想你想要的是

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

它不完全直观,我不得不阅读。我还没有机会测试这个,但似乎没有更好的方法。


I'm trying to make a simple call to retrieve user events on github through octokit.

According to the docs I create new client and visit the user events endpoint.

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

Up to here it works fine, now I continue with

events = user.events
=> nil

Alternatively, when I do

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

I get

#<Octokit::Client:0x007f9a78ac04f8...

but how to get list of events from there? Here is the official doc https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user

解决方案

I think what you want is

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

It isn't exactly intuitive and I had to read the source. I haven't had a chance to test this yet but there doesn't appear to be a better way.

这篇关于使用Github API和Octokit获取用户事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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