@fuyb1986
2016-06-24T03:38:59.000000Z
字数 2711
阅读 548
欣略
获取新闻类别
Method | Resource URL |
---|---|
GET | /news/category/ |
Name | Description | Required | Default |
---|---|---|---|
Authorization | Token 320a37f43fa80f52af27abe3b468d74204ccd180 | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' http://127.0.0.1:8000/news/category/
[
{"pk":1,"name":"生活"},
{"pk":2,"name":"政治"},
{"pk":3,"name":"军事"}
]
用户查询某一新闻信息
Method | Resource URL |
---|---|
GET | /news/${pk}/ |
Name | Description | Required | Default |
---|---|---|---|
Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/news/1/
{
"pk":3,
"author":"root",
"category":1,
"title":"未来呢",
"content":"未来一片光明",
"picture":"http://www.example.com/1.jpg",
"click":0,
"create_time":"2016-04-12 10:30:20",
}
用户获取所有新闻
Method | Resource URL |
---|---|
GET | /news/ |
默认分页取数据库中最新的10条数据
Name | Description | Required | Default |
---|---|---|---|
page | page Number | Yes | 1 |
category | 新闻资源分类pk/id | No |
curl -X GET -d 'page=1' http://127.0.0.1:8000/news/?category=1
{
"count":12,
"next":null,
"previous":null,
"results":
[
{
"pk":12,
"author":"root",
"category":1,
"title":"未来呢",
"content":"未来一片光明",
"picture":"",
"click":0,
"create_time":"2016-04-12 10:30:20",
},
{
"pk":11,
"author":"root",
"category":1,
"title":"未来呢",
"content":"未来一片光明",
"picture":"",
"click":0,
"create_time":"2016-04-12 10:30:20",
},
......
]
}
用户查看某一banner信息
Method | Resource URL |
---|---|
GET | /news/banner_ad/${pk}/ |
Name | Description | Required | Default |
---|---|---|---|
Authorization | Token 7309fabd207c22e0a00eada158989b89ffe839ef | Yes |
*Authorization的值为登录成功后返回值
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/news/banner_ad/1/
{
"pk":1,
"author":"teacher",
"title":"这是一条新闻",
"content":null,
"link":null,
"banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",
"click":0,
"create_time":"2016-04-12 10:30:20",
}
用户获取所有banner
Method | Resource URL |
---|---|
GET | /news/banner_ad/ |
默认分页取数据库中最新的10条数据
Name | Description | Required | Default |
---|---|---|---|
page | page Number | Yes | 1 |
curl -X GET http://127.0.0.1:8000/news/banner_ad/?page=1
{
"count":2,
"next":null,
"previous":null,
"results":
[
{
"pk":2,
"author":"root",
"title":"这是一条新闻",
"content":null,
"link":null,
"banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",
"click":0,
"create_time":"2016-04-12 10:30:20",
},
{
"pk":1,
"author":"root",
"title":"这是一条新闻",
"content":null,
"link":null,
"banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",
"click":0,
"create_time":"2016-04-12 10:30:20",
},
......
]
}