gpt4 book ai didi

github - 如何获取 GitHub 存储库的开放图形图像?

转载 作者:行者123 更新时间:2023-12-05 01:06:33 25 4
gpt4 key购买 nike

我一直在尝试通过 GitHub 公开的 GraphQL API 从我的存储库中获取打开的图形图像,但我总是取回我的头像。我尝试查询存储库节点、搜索和用户节点均无济于事。

例如,对于查询:

query {
repository(name: "rust-algorithms", owner: "alexfertel") {
openGraphImageUrl
nameWithOwner
}
}

我明白了:

"repository": {
"openGraphImageUrl": "https://avatars.githubusercontent.com/u/22298999?s=400&v=4",
"nameWithOwner": "alexfertel/rust-algorithms"
},

你可以看出它是一个头像,而不是 GitHub 为存储库生成的开放图形图像。

有没有办法在不涉及抓取 GitHub 的情况下获取此图像?

最佳答案

一般格式为:

https://opengraph.githubassets.com/<any_hash_number>/<owner>/<repo>

这里归功于 Reddit 上的用户 @msfjarvis

any_hash_number

我们可以在这里使用任何数字或字符串。这实际上是告诉 API 这是版本。最好使用散列,因为这样它总是会给出更新的图像。但是我们可以使用任何字符串,例如 1 , a , 或 1a .如果我们总是使用 1a它不会提供更新的图像。

关于github - 如何获取 GitHub 存储库的开放图形图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68839829/

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