发布照片
金色童年
发布照片
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
{ "author": u'布可朔夫', "description": "描述", "location": u"南柯郡汶汶乡大槐树", "photograph_set": [{ "title": "xiaoming's photo", "desc": u"南柯郡汶汶乡大槐树", "file_url": "http://www.example.com/1.jpg", "taken_date": "2016-07-01", },{ "title": "xiaoming's photo", "desc": u"南柯郡汶汶乡大槐树", "file_url": "http://www.example.com/2.jpg", "taken_date": "2016-07-01", }]}
cURL Example
curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\-H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/photograph_post/create/?album=7
Reponse
{ "count":1, "next":null, "previous":null, "results":[{ "pk":2, "author":"不可朔夫", "description":"描述", "location":"南柯郡汶汶乡大槐树", "published": "2017-02-16", "created":"2017-02-16T11:39:10.363122", "post_id": 2, "tag": "person", "photograph_set":[{ "pk":7, "title":"xiaoming's photo", "desc":"南柯郡汶汶乡大槐树", "file_url":"http://www.example.com/2.jpg", "taken_date":"2016-07-01", "taken_location":"", "author":"布可朔夫", "created":"2017-02-16T11:39:10.356554", "post_ptr": 57, "albums":[{ "album":"7", "name":"相册第一", "created":"2017-02-16T11:39:09.832258" }, { "album":"6", "name":"全部", "created":"2017-02-16T11:39:09.805213" }], "has_collect":false, "private_url":{ "url":"http://www.example.com/2.jpg", "url_1000":"http://www.example.com/2.jpg-w1000", "url_500":"http://www.example.com/2.jpg-w500", "url_150x150":"http://www.example.com/2.jpg-150x150", } }..], }]}
获取发布的照片列表
Method and URL Structure
| Method |
Resource URL |
| GET |
/photograph/photograph_post/ |
Request Paramters
| Method |
Description |
Required |
Default |
| tag |
标签 |
No |
|
cURL Example
curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\-H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/photograph_post/?tag=person
Reponse
{ "count":1, "next":null, "previous":null, "results":[{ "pk":2, "author":"不可朔夫", "description":"描述", "location":"南柯郡汶汶乡大槐树", "published": "2017-02-16", "created":"2017-02-16T11:39:10.363122", "post_id": 2, "tag": person, "photograph_set":[{ "pk":7, "title":"xiaoming's photo", "desc":"南柯郡汶汶乡大槐树", "file_url":"http://www.example.com/2.jpg", "taken_date":"2016-07-01", "taken_location":"", "author":"布可朔夫", "post_ptr": 59, "created":"2017-02-16T11:39:10.356554", "albums":[{ "album":"7", "name":"相册第一", "created":"2017-02-16T11:39:09.832258" }, { "album":"6", "name":"全部", "created":"2017-02-16T11:39:09.805213" }], "has_collect":false, "private_url":{ "url":"http://www.example.com/2.jpg", "url_1000":"http://www.example.com/2.jpg-w1000", "url_500":"http://www.example.com/2.jpg-w500", "url_150x150":"http://www.example.com/2.jpg-150x150", } }..], }]}
获取发布的照片
Method and URL Structure
| Method |
Resource URL |
| GET |
/photograph/photograph_post/${pk}/ |
cURL Example
curl -X PUT -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\-H 'Content-Type: Application/json' --data '{....}' http://localhost/photograph/photograph_post/12345/
Reponse
{ "pk":12345, "author":"test author", "description":"test description", "location":"南柯郡汶汶乡大槐树", "published":"2017-02-16", "created":"2017-02-16T14:41:24.816098" "post_id": 12345, "tag": "person", "photograph_set":[{ "pk":7, "title":"xiaoming's photo", "desc":"南柯郡汶汶乡大槐树", "file_url":"http://www.example.com/2.jpg", "taken_date":"2016-07-01", "taken_location":"", "author":"布可朔夫", "post_ptr": 61, "created":"2017-02-16T14:41:24.808831", "albums":[{ "album":"7", "name":"相册第一", "created":"2017-02-16T14:41:24.337682" },{ "album":"6", "name":"全部", "created":"2017-02-16T14:41:24.320271" }], "has_collect":false, "private_url":{ "url":"http://www.example.com/2.jpg?", "url_1000":"http://www.example.com/2.jpg-w1000", "url_500":"http://www.example.com/2.jpg-w500?", "url_150x150":"http://www.example.com/2.jpg-150x150", } },],}