[关闭]
@fuyb1986 2016-06-24T03:38:59.000000Z 字数 2711 阅读 548

新闻资讯文档

欣略


1. 获取所有新闻分类

Description

获取新闻类别

Method and URL Structure

Method Resource URL
GET /news/category/

Request Header

Name Description Required Default
Authorization Token 320a37f43fa80f52af27abe3b468d74204ccd180 Yes

*Authorization的值为登录成功后返回值

cURL Example

  1. curl -X GET -H 'Authorization: Token 320a37f43fa80f52af27abe3b468d74204ccd180' http://127.0.0.1:8000/news/category/

JSON Response

  1. [
  2. {"pk":1,"name":"生活"},
  3. {"pk":2,"name":"政治"},
  4. {"pk":3,"name":"军事"}
  5. ]

1. 查看新闻详情

Description

用户查询某一新闻信息

Method and URL Structure

Method Resource URL
GET /news/${pk}/

Request Header

Name Description Required Default
Authorization Token 7309fabd207c22e0a00eada158989b89ffe839ef Yes

*Authorization的值为登录成功后返回值

cURL Example

  1. curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/news/1/

JSON Response

  1. {
  2. "pk":3,
  3. "author":"root",
  4. "category":1,
  5. "title":"未来呢",
  6. "content":"未来一片光明",
  7. "picture":"http://www.example.com/1.jpg",
  8. "click":0,
  9. "create_time":"2016-04-12 10:30:20",
  10. }

2. 获取所有新闻信息

Description

用户获取所有新闻

Method and URL Structure

Method Resource URL
GET /news/

Request Parameters

默认分页取数据库中最新的10条数据

Name Description Required Default
page page Number Yes 1
category 新闻资源分类pk/id No

cURL Example

  1. curl -X GET -d 'page=1' http://127.0.0.1:8000/news/?category=1

JSON Response

  1. {
  2. "count":12,
  3. "next":null,
  4. "previous":null,
  5. "results":
  6. [
  7. {
  8. "pk":12,
  9. "author":"root",
  10. "category":1,
  11. "title":"未来呢",
  12. "content":"未来一片光明",
  13. "picture":"",
  14. "click":0,
  15. "create_time":"2016-04-12 10:30:20",
  16. },
  17. {
  18. "pk":11,
  19. "author":"root",
  20. "category":1,
  21. "title":"未来呢",
  22. "content":"未来一片光明",
  23. "picture":"",
  24. "click":0,
  25. "create_time":"2016-04-12 10:30:20",
  26. },
  27. ......
  28. ]
  29. }

1. 查看banner详情

Description

用户查看某一banner信息

Method and URL Structure

Method Resource URL
GET /news/banner_ad/${pk}/

Request Header

Name Description Required Default
Authorization Token 7309fabd207c22e0a00eada158989b89ffe839ef Yes

*Authorization的值为登录成功后返回值

cURL Example

  1. curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/news/banner_ad/1/

JSON Response

  1. {
  2. "pk":1,
  3. "author":"teacher",
  4. "title":"这是一条新闻",
  5. "content":null,
  6. "link":null,
  7. "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",
  8. "click":0,
  9. "create_time":"2016-04-12 10:30:20",
  10. }

2. 获取所有banner信息

Description

用户获取所有banner

Method and URL Structure

Method Resource URL
GET /news/banner_ad/

Request Parameters

默认分页取数据库中最新的10条数据

Name Description Required Default
page page Number Yes 1

cURL Example

  1. curl -X GET http://127.0.0.1:8000/news/banner_ad/?page=1

JSON Response

  1. {
  2. "count":2,
  3. "next":null,
  4. "previous":null,
  5. "results":
  6. [
  7. {
  8. "pk":2,
  9. "author":"root",
  10. "title":"这是一条新闻",
  11. "content":null,
  12. "link":null,
  13. "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",
  14. "click":0,
  15. "create_time":"2016-04-12 10:30:20",
  16. },
  17. {
  18. "pk":1,
  19. "author":"root",
  20. "title":"这是一条新闻",
  21. "content":null,
  22. "link":null,
  23. "banner_url":"http://pic.nen.com.cn/0/16/01/38/16013888_913511.jpg",
  24. "click":0,
  25. "create_time":"2016-04-12 10:30:20",
  26. },
  27. ......
  28. ]
  29. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注