-
Notifications
You must be signed in to change notification settings - Fork 6
豆瓣接口介绍
Lovemefan edited this page Apr 10, 2020
·
1 revision
豆瓣签名使用HMAC-SHA1的签名算法
HMAC-SHA1(key,data)
包含两个参数
key为密钥,data为加密信息
豆瓣接口的key值可以通过抓豆瓣登录的数据包,获得client_secret的值
https://$host$url?os_rom=android&apikey=0dad那个你懂得&channel=Douban&_sig=$sig&_ts=$ts"
分为登录状态和非登录状态
非登录状态下的data="GET&" + URLEncoder.encode(url) + "&" + ts
ts为当前时间戳,url按照上面提示的格式截取 如
GET frodo.douban.com/api/v2/subject_collection/movie_hot_gaia/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
其中data = GET&%2Fapi%2Fv2%2Fskynet%2Fnew_playlists&1585718766
登录状态下http的头部会多出一个参数,如下:
Authorization: Bearer 9931b7883f68a4dbcb952698be39ee91
登录状态下的data="GET&" + URLEncoder.encode(url) + "&9931b7883f68a4dbcb952698be39ee91" +"&" + ts
此时的data = GET&%2Fapi%2Fv2%2Fskynet%2Fnew_playlists&9931b7883f68a4dbcb952698be39ee91&1585718766
算法js代码实现在TZVideo项目中点这里
==注意哦== header一定要加User-agent
最后得到的加密签名为 encodeURIComponent(HMAC-SHA1(key,sigString))
GET frodo.douban.com/api/v2/subject_collection/movie_hot_gaia/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/subject_collection/tv_hot/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/subject_collection/tv_domestic/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/subject_collection/tv_american/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/subject_collection/tv_japanese/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/subject_collection/tv_korean/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/subject_collection/tv_animation/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET /api/v2/subject_collection/show_foreign/items?start=0&count=20&udid=a4684a67c5db66436da276d582163766f927d703&rom=android&apikey=0dad551ec0f84ed02907ff5c42e8ec70&s=rexxar_new&channel=Douban&device_id=a4684a67c5db66436da276d582163766f927d703&os_rom=android&apple=49db722f1873da2794d1345d984636c2&icecream=f19780352d2a7036d216fad19e8ebee3&mooncake=65316193bbe4cb682856b448f447a4a7&sugar=46007&loc_id=118215&_sig=peOCRQGOKWrxlsy9%2F%2BYSq6RPmFk%3D&_ts=1585240659 HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
getc参数只需要保留start,count,category,apikey,channel
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=all&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=selected&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=classical&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=official&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
GET frodo.douban.com/api/v2/skynet/new_playlists?start=0&count=20&category=official&apikey=0dad551ec0f84ed02907ff5c42e8ec70&channel=Douban
HTTP/1.1
User-Agent: Rexxar-Core/0.1.3 api-client/1 com.douban.frodo/6.32.0(180) Android/22 product/R11 vendor/OPPO model/OPPO R11 rom/android network/wifi platform/mobile com.douban.frodo/6.32.0(180) Rexxar/1.2.151 platform/mobile 1.2.151
Host: frodo.douban.com
Connection: Keep-Alive
Accept-Encoding: gzip
根据category的参返回不同的片单,category的 参数为下面key值
categories": [
{
"items": [
{
"key": "all",
"title": "全部"
},
{
"key": "official",
"title": "豆瓣片单"
},
{
"key": "selected",
"title": "精选"
},
{
"key": "classical",
"title": "经典"
},
{
"key": "prize",
"title": "获奖"
},
{
"key": "high_score",
"title": "高分"
},
{
"key": "movie_list",
"title": "榜单"
},
{
"key": "dark_horse",
"title": "冷门佳片"
}
],
"name": "全部"
},
{
"items": [
{
"key": "chinese",
"title": "华语"
},
{
"key": "western",
"title": "欧美"
},
{
"key": "japanese",
"title": "日本"
},
{
"key": "korea",
"title": "韩国"
}
],
"name": "地域"
},
{
"items": [
{
"key": "comedy",
"title": "喜剧"
},
{
"key": "love",
"title": "爱情"
},
{
"key": "science_fiction",
"title": "科幻"
},
{
"key": "cartoon",
"title": "动画"
},
]
}