[关闭]
@fuyb1986 2017-03-01T09:33:28.000000Z 字数 3768 阅读 570

发布照片

金色童年


发布照片

Method and URL Structure

Method Resource URL
POST /photograph/photograph_post/create/

Request Data

Name Description Required Default
author 作者 NO
description 描述 YES
location 拍摄地点 YES
photograph_set 照片集合 YES
tag 标签 No person

Requeset Parameters

Name Description Required Default
album 相册 YES

Request

  1. {
  2. "author": u'布可朔夫',
  3. "description": "描述",
  4. "location": u"南柯郡汶汶乡大槐树",
  5. "photograph_set": [{
  6. "title": "xiaoming's photo",
  7. "desc": u"南柯郡汶汶乡大槐树",
  8. "file_url": "http://www.example.com/1.jpg",
  9. "taken_date": "2016-07-01",
  10. },{
  11. "title": "xiaoming's photo",
  12. "desc": u"南柯郡汶汶乡大槐树",
  13. "file_url": "http://www.example.com/2.jpg",
  14. "taken_date": "2016-07-01",
  15. }]
  16. }

cURL Example

  1. curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. -H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/photograph_post/create/?album=7

Reponse

  1. {
  2. "count":1,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":2,
  7. "author":"不可朔夫",
  8. "description":"描述",
  9. "location":"南柯郡汶汶乡大槐树",
  10. "published": "2017-02-16",
  11. "created":"2017-02-16T11:39:10.363122",
  12. "post_id": 2,
  13. "tag": "person",
  14. "photograph_set":[{
  15. "pk":7,
  16. "title":"xiaoming's photo",
  17. "desc":"南柯郡汶汶乡大槐树",
  18. "file_url":"http://www.example.com/2.jpg",
  19. "taken_date":"2016-07-01",
  20. "taken_location":"",
  21. "author":"布可朔夫",
  22. "created":"2017-02-16T11:39:10.356554",
  23. "post_ptr": 57,
  24. "albums":[{
  25. "album":"7",
  26. "name":"相册第一",
  27. "created":"2017-02-16T11:39:09.832258"
  28. }, {
  29. "album":"6",
  30. "name":"全部",
  31. "created":"2017-02-16T11:39:09.805213"
  32. }],
  33. "has_collect":false,
  34. "private_url":{
  35. "url":"http://www.example.com/2.jpg",
  36. "url_1000":"http://www.example.com/2.jpg-w1000",
  37. "url_500":"http://www.example.com/2.jpg-w500",
  38. "url_150x150":"http://www.example.com/2.jpg-150x150",
  39. }
  40. }..],
  41. }]
  42. }

获取发布的照片列表

Method and URL Structure

Method Resource URL
GET /photograph/photograph_post/

Request Paramters

Method Description Required Default
tag 标签 No

cURL Example

  1. curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. -H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/photograph_post/?tag=person

Reponse

  1. {
  2. "count":1,
  3. "next":null,
  4. "previous":null,
  5. "results":[{
  6. "pk":2,
  7. "author":"不可朔夫",
  8. "description":"描述",
  9. "location":"南柯郡汶汶乡大槐树",
  10. "published": "2017-02-16",
  11. "created":"2017-02-16T11:39:10.363122",
  12. "post_id": 2,
  13. "tag": person,
  14. "photograph_set":[{
  15. "pk":7,
  16. "title":"xiaoming's photo",
  17. "desc":"南柯郡汶汶乡大槐树",
  18. "file_url":"http://www.example.com/2.jpg",
  19. "taken_date":"2016-07-01",
  20. "taken_location":"",
  21. "author":"布可朔夫",
  22. "post_ptr": 59,
  23. "created":"2017-02-16T11:39:10.356554",
  24. "albums":[{
  25. "album":"7",
  26. "name":"相册第一",
  27. "created":"2017-02-16T11:39:09.832258"
  28. }, {
  29. "album":"6",
  30. "name":"全部",
  31. "created":"2017-02-16T11:39:09.805213"
  32. }],
  33. "has_collect":false,
  34. "private_url":{
  35. "url":"http://www.example.com/2.jpg",
  36. "url_1000":"http://www.example.com/2.jpg-w1000",
  37. "url_500":"http://www.example.com/2.jpg-w500",
  38. "url_150x150":"http://www.example.com/2.jpg-150x150",
  39. }
  40. }..],
  41. }]
  42. }

获取发布的照片

Method and URL Structure

Method Resource URL
GET /photograph/photograph_post/${pk}/

cURL Example

  1. curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\
  2. -H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/photograph_post/12345/

Reponse

  1. {
  2. "pk":12345,
  3. "author":"test author",
  4. "description":"test description",
  5. "location":"南柯郡汶汶乡大槐树",
  6. "published":"2017-02-16",
  7. "created":"2017-02-16T14:41:24.816098"
  8. "post_id": 12345,
  9. "tag": "person",
  10. "photograph_set":[{
  11. "pk":7,
  12. "title":"xiaoming's photo",
  13. "desc":"南柯郡汶汶乡大槐树",
  14. "file_url":"http://www.example.com/2.jpg",
  15. "taken_date":"2016-07-01",
  16. "taken_location":"",
  17. "author":"布可朔夫",
  18. "post_ptr": 61,
  19. "created":"2017-02-16T14:41:24.808831",
  20. "albums":[{
  21. "album":"7",
  22. "name":"相册第一",
  23. "created":"2017-02-16T14:41:24.337682"
  24. },{
  25. "album":"6",
  26. "name":"全部",
  27. "created":"2017-02-16T14:41:24.320271"
  28. }],
  29. "has_collect":false,
  30. "private_url":{
  31. "url":"http://www.example.com/2.jpg?",
  32. "url_1000":"http://www.example.com/2.jpg-w1000",
  33. "url_500":"http://www.example.com/2.jpg-w500?",
  34. "url_150x150":"http://www.example.com/2.jpg-150x150",
  35. }
  36. },],
  37. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注