gpt4 book ai didi

http - 如何为用户的固定存储库对 GitHub 进行 API 调用?

转载 作者:可可西里 更新时间:2023-11-01 15:16:29 30 4
gpt4 key购买 nike

在 GitHub 上,用户可以拥有 pinned repositories .

还有 Repositories API 的一部分描述了如何发出涉及 repos 的请求。您还可以获得有关用户所属组织的信息,如 another answer 中所述。 (可以固定)。

但是,我想访问用户的固定存储库。例如,给出以下配置文件:

enter image description here

我希望能够做到以下几点:

$ curl -s <some endpoint with some parameters> | <some pipeline with some filtering>
str
liffy_diffy
spiralify
micro-twitter
kit
xdoc

所以我想知道:

  • 我需要什么端点和参数来获取用户的固定存储库?

我能够使用 nokogiri gem 来解析 html。但是,似乎我应该是 api 来通过简单的 HTTP 请求完成同样的事情:

$ ./get_user_pinned_repos mbigras
str
liffy_diffy
spiralify
micro-twitter
kit
xdoc

代码:

#!/usr/bin/env ruby
# get a user's pinned repos
require 'rubygems'
require 'nokogiri'
require 'open-uri'

if ARGV.length != 1
STDERR.puts "usage: get_user_pinned_repos <username>"
exit 1
end

username = ARGV.first
profile_url = "https://github.com/#{username}"
page = Nokogiri::HTML(open(profile_url))
page.css("span.repo").each { |repo| puts repo.text }

最佳答案

对原始答案的更新:

changelog对于 GitHub GraphQL 架构 (2019-03-30) 提到pinnedRepositories 将于 2019 年 7 月 1 日弃用或删除。要求 GraphQL API 用户改用 ProfileOwner.pinnedItems

使用 ProfileOwner.pinnedItems 检索固定存储库的示例:

示例 1:

query {
user(login:"kranthilakum") {
pinnedItems(first: 5, types: [REPOSITORY, GIST]) {
totalCount
edges {
node {
... on Repository {
name
}
}
}
}
}
}

Try Example 1 in the GraphQL API Explorer

示例 2:

query {
repositoryOwner(login: "kranthilakum") {
... on ProfileOwner {
pinnedItemsRemaining
itemShowcase {
items(first: 5) {
totalCount
edges {
node {
... on Repository {
name
}
}
}
}
hasPinnedItems
}
}
}
}

Try Example 2 in GraphQL API Explorer

关于http - 如何为用户的固定存储库对 GitHub 进行 API 调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43352056/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com