求助 关于豆瓣电台的API

遇到了问题?请先进行搜索(中文和英文),然后在此提问

Moderators: tmplinshi, arcticir

arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

求助 关于豆瓣电台的API

06 Oct 2014, 10:55

看到这个 豆瓣FM API 的资料
忍不住想用AHK写一个,豆瓣的客户端我已经受够了。。。
可惜的是,完全不会网页操作这部分啊,求助啊,临时~~~

https://github.com/zonyitoo/doubanfm-qt ... 3%A3FM-API

正在尝试中。。。
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: 求助 关于豆瓣电台的API

06 Oct 2014, 11:04

找个似乎差不多的代码,修改中。。。

Code: Select all

;Prepare our WinHttpRequest object
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
;HttpObj.SetProxy(2,"localhost:8888") ;Send data through Fiddler
HttpObj.SetTimeouts(6000,6000,6000,6000) ;Set timeouts to 6 seconds
;HttpObj.Option(6) := False ;disable location-header rediects

;Set our URLs
loginSiteURL := "http://www.autohotkey.com/board/index.php?app=core&module=global&section=login"
loginURL := "http://www.autohotkey.com/board/index.php?app=core&module=global&section=login&do=process"

;Set our login data
username := "Brutosozialprodukt"
password := "xxxxxxxxxxxxxx"
rememberMe := "1"

;Step 1
HttpObj.Open("GET",loginSiteURL)
HttpObj.Send()

;Step 2
RegExMatch(HttpObj.ResponseText,"<input\stype='hidden'\sname='auth_key'\svalue='(\w+)'\s/>",match)
auth_key := match1

;Step 3
loginBody := "auth_key=" auth_key "&ips_username=" username "&ips_password=" password "&rememberMe=" rememberMe

;Step 4/5
HttpObj.Open("POST",loginURL)
HttpObj.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
HttpObj.Send(loginBody)

;Step 6
If (InStr(HttpObj.ResponseText,"<title>Sign In"))
    MsgBox, The login failed!
Else
    MsgBox, Login was successfull!
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: 求助 关于豆瓣电台的API

06 Oct 2014, 11:08

丫的不按套路来啊
这个咋两个地址?

Code: Select all

loginSiteURL := "http://www.autohotkey.com/board/index.php?app=core&module=global&section=login"
loginURL := "http://www.autohotkey.com/board/index.php?app=core&module=global&section=login&do=process"
豆瓣只给一个

Code: Select all

URL: http://www.douban.com/j/app/login
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: 求助 关于豆瓣电台的API

06 Oct 2014, 11:16

成功了 :D
登陆接口完成。

Code: Select all

;Prepare our WinHttpRequest object
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
;HttpObj.SetProxy(2,"localhost:8888") ;Send data through Fiddler
HttpObj.SetTimeouts(6000,6000,6000,6000) ;Set timeouts to 6 seconds
;HttpObj.Option(6) := False ;disable location-header rediects

;Set our URLs
loginURL := "http://www.douban.com/j/app/login"

;Set our login data
email := "kongqir@gmail.com"
password := "kongqir"


;Step 1
loginBody := "email=" email "&password=" password "&app_name=radio_desktop_win&version=100"

;Step 2/3
HttpObj.Open("POST",loginURL)
HttpObj.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
HttpObj.Send(loginBody)

MsgBox % HttpObj.ResponseText
;Step 4
If (InStr(HttpObj.ResponseText,"<title>Login"))
    MsgBox, The login failed!
Else
    MsgBox, Login was successfull!




arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: 求助 关于豆瓣电台的API

06 Oct 2014, 11:22

获取频道列表完成。

MsgBox % Z_Com("http://www.douban.com/j/app/radio/channels")

Z_Com(h:="http://61.135.169.125/forbiddenip/forbidden.html", c:="", p:=""){
comobjerror(false),x := comobjcreate("winhttp.winhttprequest.5.1"),(p?x.setproxy(2, p):""),x.open("get",h,true)
,x.setrequestheader("user-agent", "mozilla/5.0 (windows nt 5.1; rv:11.0) gecko/20100101 firefox/11.0"), x.send(), x.WaitForResponse(-1)
if c {
s:=comobjcreate("adodb.stream"), s.type := 1, s.mode := 3, s.open(), s.write(x.responsebody), s.position := 0, s.type := 2, s.charset := c
return s.readtext(),s.close()
}
else return x.responsetext
}
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: 求助 关于豆瓣电台的API

06 Oct 2014, 11:39

难道又换套路了,无法获取歌曲列表,提示说 version 错误

Code: Select all

;Prepare our WinHttpRequest object
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
;HttpObj.SetProxy(2,"localhost:8888") ;Send data through Fiddler
HttpObj.SetTimeouts(6000,6000,6000,6000) ;Set timeouts to 6 seconds
;HttpObj.Option(6) := False ;disable location-header rediects

;Set our URLs
loginURL := "http://www.douban.com/j/app/radio/people"



;Step 1
loginBody := "app_name=radio_desktop_win&version=100&type=p"

;Step 2/3
HttpObj.Open("GET",loginURL)
HttpObj.Send(loginBody)

MsgBox % HttpObj.ResponseText
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: 求助 关于豆瓣电台的API

06 Oct 2014, 12:34

临时帮我解决了最后一步。再无障碍。

Code: Select all

MsgBox % Z_Com("http://www.douban.com/j/app/radio/people?app_name=radio_desktop_win&version=100&type=n&channel=1")
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: 求助 关于豆瓣电台的API

07 Oct 2014, 00:04

这属于示例/作品展示了..
不过帖子有点长,有点乱..
我为人人,人人为己?
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: 求助 关于豆瓣电台的API

07 Oct 2014, 01:39

完成会在展示区发布的。

接下来就是GUI了。
我打算写个类似安卓通知中心一样的伸缩栏
用于控制这些模块。
不过有些困难啊,功能倒好实现,就是写不美观。。。丑是原罪啊
User avatar
RobertL
Posts: 546
Joined: 18 Jan 2014, 01:14
Location: China

Re: 求助 关于豆瓣电台的API

07 Oct 2014, 01:58

干脆写简单点,朴实美...
那些界面最好现有库积累,而不是每次都从头搭建,不过库也是从头开始的..
我为人人,人人为己?

Return to “请求帮助”

Who is online

Users browsing this forum: No registered users and 15 guests