|
|
## 列表
|
|
|
|
|
|
## 详情
|
|
|
## Host
|
|
|
```
|
|
|
https://codechina.csdn.net
|
|
|
```
|
|
|
## 接口
|
|
|
目前仅用到 code 平台获取仓库文件内容接口:
|
|
|
```
|
|
|
GET /projects/:id/repository/files/:file_path/raw
|
|
|
```
|
|
|
```
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://codechina.csdn.net/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb/raw?ref=master"
|
|
|
```
|
|
|
Parameters:
|
|
|
|
|
|
## 正文 |
|
|
\ No newline at end of file |
|
|
* `file_path` (required) - URL encoded full path to new file, such as lib%2Fclass%2Erb.
|
|
|
* `ref` (optional) - The name of branch, tag or commit. Default is the HEAD of the project.
|
|
|
|
|
|
[官方文档地址](https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository)
|
|
|
## 接口请求方式
|
|
|
codechina 基于 gitlab 引擎实现,遵循 restful 规范,所有接口请求方式与 gitlab 一致,请求 header 中需包含校验信息 `PRIVATE-TOKEN`。
|
|
|
如:
|
|
|
```
|
|
|
curl --header "PRIVATE-TOKEN: KSWGFaQPt5DSEcwjq-z" "https://codechina.csdn.net/api/v4/projects/codechina%2Fprogrammer%2F10-years-of-mobile-dev/repository/files/detail.json/raw?ref=master"
|
|
|
```
|
|
|
## 访问令牌
|
|
|
注意:所有接口请求 header 中都必须包含访问令牌
|
|
|
```
|
|
|
PRIVATE-TOKEN
|
|
|
```
|
|
|
## 业务调用方式:
|
|
|
### 获取杂志列表
|
|
|
```
|
|
|
GET /api/v4/projects/codechina%2Fprogrammer%2Fprogramer_magazine_list/repository/files/list.json/raw?ref=master
|
|
|
```
|
|
|
```
|
|
|
{
|
|
|
"default_index": [
|
|
|
{
|
|
|
"id": "1",
|
|
|
"title": "《移动开发十年》",
|
|
|
"path": "codechina/programmer/10-years-of-mobile-dev",
|
|
|
"detail": "detail.json",
|
|
|
"chapters": "chapters.json",
|
|
|
"ref": "master",
|
|
|
"list_image": "https://images.gitbook.cn/Fg_-eDnBvuAVxBrBv2vjzMpQ3e3E",
|
|
|
"original_price": "19.9",
|
|
|
"line_price": "19.9",
|
|
|
"sale_price": "9.9",
|
|
|
"short_description": "我们特别组织了数十位开发者,一方面,是十年改变与回顾...",
|
|
|
"author": {
|
|
|
"username": "programer",
|
|
|
"user_title": "国内开发者的权威刊物",
|
|
|
"nickname": "程序员杂志编辑组"
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
`default_index`: 默认排序列表(后面可拓展出其他排序,如:hot_index)
|
|
|
`id`:刊物唯一ID(由编辑人员自行定义,如:1)
|
|
|
`title`:刊物标题
|
|
|
`path`:刊物在 code 上的路径(刊物在 code 平台的唯一标识之一,关键字段,可作为项目id使用,使用时必须将 `\` 转译为 `%2F`)
|
|
|
`detail`:详情文件(由编辑定义,协议定为:`detail.json`,程序需根据实际值使用,不可直接采用 `detail.json`)
|
|
|
`chapters`:章节文件(协议定为:`chapters.json`)
|
|
|
`ref`:分支(必要字段,默认为:`master`)
|
|
|
`list_image`:列表图
|
|
|
`original_price`:原价
|
|
|
`line_price`:划线价格
|
|
|
`sale_price`:售价
|
|
|
`short_description`:短描述
|
|
|
`author`:作者
|
|
|
* `username`:用户名
|
|
|
* `user_title`:用户 title
|
|
|
* `nickname`:昵称
|
|
|
|
|
|
*注意:上面 demo 中 `codechina%2Fprogrammer%2Fprogramer_magazine_list` 由 `path` 值转译而来,`list.json` 为协议固定文件名称,`master` 为 `ref` 值。*
|
|
|
### 获取杂志详情
|
|
|
```
|
|
|
GET /api/v4/projects/codechina%2Fprogrammer%2F10-years-of-mobile-dev/repository/files/detail.json/raw?ref=master
|
|
|
```
|
|
|
```
|
|
|
{
|
|
|
"id": "1",
|
|
|
"title": "《移动开发十年》",
|
|
|
"path": "codechina/programmer/10-years-of-mobile-dev",
|
|
|
"detail_image": "https://images.gitbook.cn/Fg_-eDnBvuAVxBrBv2vjzMpQ3e3E",
|
|
|
"share_image": "https://images.gitbook.cn/Fg_-eDnBvuAVxBrBv2vjzMpQ3e3E",
|
|
|
"original_price": "19.9",
|
|
|
"line_price": "19.9",
|
|
|
"sale_price": "9.9",
|
|
|
"short_description": "我们特别组织了数十位开发者,一方面,是十年改变与回顾...",
|
|
|
"chapters": "chapters.json",
|
|
|
"description": "<div id=\"content_views\" class=\"htmledit_views\">\n <div align=\"center\">\n <strong><img height=\"240\" alt=\"\" src=\"https://p-blog.csdn.net/images/p_blog_csdn_net/programmer_editor/EntryImages/20080826/fengmian.jpg\" width=\"190\" align=\"center\"></strong>\n</div> \n<div>\n <strong></strong> \n</div> \n<div>\n <strong>本期特别策划</strong>\n ...",
|
|
|
"author": {
|
|
|
"username": "programer",
|
|
|
"user_title": "国内开发者的权威刊物",
|
|
|
"nickname": "程序员杂志编辑组"
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
`id`:刊物唯一ID(由编辑人员自行定义,如:1)
|
|
|
`title`:刊物标题
|
|
|
`path`:刊物在 code 上的路径(刊物在 code 平台的唯一标识之一,关键字段,可作为项目id使用,使用时必须将 `\` 转译为 `%2F`)
|
|
|
`detail`:详情文件(由编辑定义,协议定为:`detail.json`,程序需根据实际值使用,不可直接采用 `detail.json`)
|
|
|
`chapters`:章节文件(协议定为:`chapters.json`)
|
|
|
`ref`:分支(必要字段,默认为:`master`)
|
|
|
`detail_image`:详情图
|
|
|
`share_image`:分享图
|
|
|
`original_price`:原价
|
|
|
`line_price`:划线价格
|
|
|
`sale_price`:售价
|
|
|
`description`:描述支持 `text` 和 `html` 格式
|
|
|
`short_description`:短描述 `text` 格式,可作为分享描述
|
|
|
`author`:作者
|
|
|
* `username`:用户名
|
|
|
* `user_title`:用户 title
|
|
|
* `nickname`:昵称
|
|
|
|
|
|
*注意:上面 demo 中 `detail.json` 为列表接口中返回的 `detail` 字段值,需以列表中具体值为准,如 `detail` 中包含 `/`,需转译为 `%2F`。*
|
|
|
### 获取杂志章节列表
|
|
|
```
|
|
|
GET /api/v4/projects/codechina%2Fprogrammer%2F10-years-of-mobile-dev/repository/files/chapters.json/raw?ref=master
|
|
|
```
|
|
|
```
|
|
|
{
|
|
|
"chapters": [
|
|
|
{
|
|
|
"id": "1",
|
|
|
"title": "十年一顾,iOS 与 Android 这样改变了我们",
|
|
|
"sub_title": "文/胡凯",
|
|
|
"index": "1",
|
|
|
"description": "基于本地数据的全文搜索(Full-Text-Search,简称 FTS)在移动应用上扮演着重要角色,与基于服务端提供的搜索服务不同,移动端受硬件条件限制,尤其在数据量相对较大的情况下,搜索性能问题表现得十分突出。本文以移动平台广泛采用的 SQLite FTS Extension 为例,介绍了移动平台 FTS 的基本原理,并结合微信 Android 客户端自身实践,重点讲述微信在 FTS 上的一些性能优化经验。",
|
|
|
"chapter_page_url": "https://codechina.gitcode.host/programmer/10-years-of-mobile-dev/1-10-years-ios-and-android.html"
|
|
|
},
|
|
|
{
|
|
|
"id": "2",
|
|
|
"title": "58同城 iOS 客户端网络框架的演进之路",
|
|
|
"sub_title": "文/郭方清",
|
|
|
"index": "2",
|
|
|
"description": "伴随着业务场景需求的变化,58同城 App 在网络架构层面经历了从使用第三方开源网络框架到自主研发框架的不同阶段的不断改进。本文作者即从 iOS 开发角度具体分享了58同城移动客户端在网络框架层面的几次演变改进实践与经验总结。",
|
|
|
"chapter_page_url": "https://codechina.gitcode.host/programmer/10-years-of-mobile-dev/2-58-app-architecture.html"
|
|
|
},
|
|
|
...
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
`id`:唯一ID
|
|
|
`title`:章节标题
|
|
|
`sub_title`:副标题
|
|
|
`index`:章节排序
|
|
|
`description`:章节描述
|
|
|
`chapter_page_url`:章节内容页面地址
|
|
|
### 正文
|
|
|
```
|
|
|
GET web_url
|
|
|
```
|
|
|
```
|
|
|
https://codechina.gitcode.host/programmer/10-years-of-mobile-dev/1-10-years-ios-and-android.html
|
|
|
``` |
|
|
\ No newline at end of file |