Skip to content

Instantly share code, notes, and snippets.

@yesmeck
Created September 27, 2012 12:52
Show Gist options
  • Save yesmeck/3793842 to your computer and use it in GitHub Desktop.
Save yesmeck/3793842 to your computer and use it in GitHub Desktop.
豆瓣 API

获取讨论列表GET https://api.douban.com/v2/target/:id/discussions这里的 target 是不是要替换成 movie、book 这样的?不管我怎么弄都是返回 404。

% http GET https://api.douban.com/v2/target/1915561/discussions  -v
GET /v2/target/1915561/discussions HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Host: api.douban.com
User-Agent: HTTPie/0.3.0



HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Thu, 27 Sep 2012 14:19:37 GMT
Expires: -1
Keep-Alive: timeout=10
Server: nginx
Transfer-Encoding: chunked

The requested link does not exist on this site.  If you arrived here by following a link from an external page, please inform that page's maintainer.
% http GET https://api.douban.com/v2/music/1915561/discussions -v
GET /v2/music/1915561/discussions HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Host: api.douban.com
User-Agent: HTTPie/0.3.0



HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Thu, 27 Sep 2012 14:20:18 GMT
Expires: -1
Keep-Alive: timeout=10
Server: nginx
Transfer-Encoding: chunked

The requested link does not exist on this site.  If you arrived here by following a link from an external page, please inform that page's maintainer.

新发讨论

% http --form POST https://api.douban.com/v2/target/2277204/discussions Authorization:"Bearer ee10c85e43905bcfca32591acab1136d"  title=测试 content=测试 -v
POST /v2/target/2277204/discussions HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Authorization: Bear ee10c85e43905bcfca32591acab1136d
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: api.douban.com
User-Agent: HTTPie/0.3.0

title=%E6%B5%8B%E8%AF%95&content=%E6%B5%8B%E8%AF%95

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Thu, 27 Sep 2012 14:17:57 GMT
Expires: -1
Keep-Alive: timeout=10
Server: nginx
Transfer-Encoding: chunked

The requested link does not exist on this site.  If you arrived here by following a link from an external page, please inform that page's maintainer.

还有对豆邮的操作都返回 invalid_credencial1,看错误应该是没有这个 api 的授权,但是我在获取 access_token 的时候是请求了所有 api 的权限的,是否跟我用的 api key 是没审核的有关?

% http -f POST https://api.douban.com/v2/doumails title=测试 content=测试 receiver_id=hualunlun Authorization:"Bearer ee10c85e43905bcfca32591acab1136d"  -v
POST /v2/doumails HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Authorization: Bearer ee10c85e43905bcfca32591acab1136d
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: api.douban.com
User-Agent: HTTPie/0.2.7

title=%E6%B5%8B%E8%AF%95&content=%E6%B5%8B%E8%AF%95&receiver_id=hualunlun


HTTP/1.1 400 Bad Request
Connection: keep-alive
Content-Length: 72
Content-Type: application/json; charset=utf-8
Date: Thu, 27 Sep 2012 14:27:24 GMT
Expires: -1
Keep-Alive: timeout=10
Server: nginx

{
    "code": 108, 
    "msg": "invalid_credencial1", 
    "request": "POST /v2/doumails"
}

音乐搜索返回 500

% http --form GET https://api.douban.com/v2/music/search q="The Black Parade" start=0 count=10
GET /v2/music/search HTTP/1.1
Host: api.douban.com
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Accept-Encoding: identity, deflate, compress, gzip
Accept: */*
User-Agent: HTTPie/0.2.7

q=The+Black+Parade&start=0&count=10


HTTP/1.1 500 Internal Server Error
Server: nginx
Content-Type: text/html
Content-Length: 4020
Connection: keep-alive
Keep-Alive: timeout=10
Content-Encoding: gzip
Date: Thu, 27 Sep 2012 13:28:36 GMT
Expires: -1

<!DOCTYPE html>
    <html lang="zh-CN" class="">
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>豆瓣错误</title>
..........

获取用户对书影音的 tags 都返回没有 tag 实际上当前的认证用户是有 tag 的。

用户对电影的所有标签

% http GET  https://api.douban.com/v2/movie/user_tags/1307931 Authorization:"Bearer ee10c85e43905bcfca32591acab1136d"  -v
GET /v2/movie/user_tags/1307931 HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Authorization: Bearer ee10c85e43905bcfca32591acab1136d
Host: api.douban.com
User-Agent: HTTPie/0.2.7


HTTP/1.1 200 OK
Cache-Control: must-revalidate, no-cache, private
Connection: keep-alive
Content-Length: 31
Content-Type: application/json; charset=utf-8
Date: Thu, 27 Sep 2012 12:54:26 GMT
Expires: Sun, 1 Jan 2006 01:00:00 GMT
Keep-Alive: timeout=10
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Pragma: no-cache
Server: nginx
Set-Cookie: bid="TaiaTJ0JQKI"; path=/; domain=.douban.com; expires=Fri, 27-Sep-2013 12:54:26 GMT
X-Ratelimit-Limit: 150
X-Ratelimit-Limit2: 10000
X-Ratelimit-Remaining: 139
X-Ratelimit-Remaining2: 9989

{
    "count": 0, 
    "start": 0, 
    "total": 0
}

用户对图书的所有标签

% http GET  https://api.douban.com/v2/book/user_tags/1084336 Authorization:"Bearer ee10c85e43905bcfca32591acab1136d"  -v 
GET /v2/book/user_tags/1084336 HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Authorization: Bearer ee10c85e43905bcfca32591acab1136d
Host: api.douban.com
User-Agent: HTTPie/0.2.7


HTTP/1.1 200 OK
Cache-Control: must-revalidate, no-cache, private
Connection: keep-alive
Content-Length: 41
Content-Type: application/json; charset=utf-8
Date: Thu, 27 Sep 2012 12:57:03 GMT
Expires: Sun, 1 Jan 2006 01:00:00 GMT
Keep-Alive: timeout=10
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Pragma: no-cache
Server: nginx
Set-Cookie: bid="pkdbFi7xvJ0"; path=/; domain=.douban.com; expires=Fri, 27-Sep-2013 12:57:03 GMT
X-Ratelimit-Limit: 150
X-Ratelimit-Limit2: 10000
X-Ratelimit-Remaining: 137
X-Ratelimit-Remaining2: 9987

{
    "count": 0, 
    "start": 0, 
    "tags": [], 
    "total": 0
}

用户对图书的所有标签

% http GET  https://api.douban.com/v2/music/user_tags/1899400 Authorization:"Bearer ee10c85e4
3905bcfca32591acab1136d"  -v                                                                 
GET /v2/music/user_tags/1899400 HTTP/1.1
Accept: */*
Accept-Encoding: identity, deflate, compress, gzip
Authorization: Bearer ee10c85e43905bcfca32591acab1136d
Host: api.douban.com
User-Agent: HTTPie/0.2.7


HTTP/1.1 200 OK
Cache-Control: must-revalidate, no-cache, private
Connection: keep-alive
Content-Length: 31
Content-Type: application/json; charset=utf-8
Date: Thu, 27 Sep 2012 13:00:04 GMT
Expires: Sun, 1 Jan 2006 01:00:00 GMT
Keep-Alive: timeout=10
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Pragma: no-cache
Server: nginx
Set-Cookie: bid="T+heCcRwDtc"; path=/; domain=.douban.com; expires=Fri, 27-Sep-2013 13:00:04 
GMT
X-Ratelimit-Limit: 150
X-Ratelimit-Limit2: 10000
X-Ratelimit-Remaining: 149
X-Ratelimit-Remaining2: 9999

{
    "count": 0, 
    "start": 0, 
    "total": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment