#223 串接 GitHub API 顯示可愛的程式 logo

最近看到 SAWARATSUKI 大大在 GitHub 分享他繪製的可愛程式 logo,有興趣的朋友也可以串接 GitHub API 做個顯示可愛程式 logo 的 App。

功能需求

  • 第一頁顯示名字列表。

使用以下 API 抓取名字列表。

https://api.github.com/repos/SAWARATSUKI/ServiceLogos/contents

欄位 name 是名字,url 是下一頁抓取圖片資訊的網址。

  • 第二頁顯示圖片。

從第一頁 JSON 裡的 url 抓取圖片資訊,比方用以下網址抓取 Swift 的資訊。

https://api.github.com/repos/SAWARATSUKI/ServiceLogos/contents/Swift

從 JSON 的 download_url 取得圖片網址。

[
{
"name": "Swift.png",
"path": "Swift/Swift.png",
"sha": "807b288fc745c750d7843c1bad4f0f351c267553",
"size": 87573,
"url": "https://api.github.com/repos/SAWARATSUKI/ServiceLogos/contents/Swift/Swift.png?ref=main",
"html_url": "https://github.com/SAWARATSUKI/ServiceLogos/blob/main/Swift/Swift.png",
"git_url": "https://api.github.com/repos/SAWARATSUKI/ServiceLogos/git/blobs/807b288fc745c750d7843c1bad4f0f351c267553",
"download_url": "https://raw.githubusercontent.com/SAWARATSUKI/ServiceLogos/main/Swift/Swift.png",
"type": "file",
"_links": {
"self": "https://api.github.com/repos/SAWARATSUKI/ServiceLogos/contents/Swift/Swift.png?ref=main",
"git": "https://api.github.com/repos/SAWARATSUKI/ServiceLogos/git/blobs/807b288fc745c750d7843c1bad4f0f351c267553",
"html": "https://github.com/SAWARATSUKI/ServiceLogos/blob/main/Swift/Swift.png"
}
}
]

--

--

彼得潘的 iOS App Neverland
彼得潘的 100 道 Swift iOS App 謎題

彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,彼得潘的 Swift 程式設計入門,App程式設計入門作者,http://apppeterpan.strikingly.com