![Douban](http://photohost.info/images/9521.png)
![分析获取请求的数据](http://photohost.info/images/5795.png)
http://www.douban.com/j/app/radio/liked_songs?count=10&token=7sasda19f525&exclude=&version=606&client=s%3Amobile%7Cy%3Aandroid+2.3.5%7Cf%3A606%7Cm%3ADouban%7Cd%3A-1629744272%7Ce%3Ahkcsl_cht_htc_desire_s&app_name=radio_android&from=android_606_Douban&user_id=153edsa182&expire=1351265604&formats=aac修改 count 值到 200
![修改获取的数量](http://photohost.info/images/7346.png)
{"err":"invalid_token", "r":1}下面的问题就很清楚了,我们需要怎么获得 token 和 user_id. 而在 wireshark 里面获取的包中,并没有相关的内容(这个我找了好久),按照经验来说获取令牌和用户 ID 应该是在登陆的过程产生的,当我们重复登陆过程的时候,发现:
![找到Https](http://photohost.info/images/9017.png)
![查看Https内容](http://photohost.info/images/9978.png)
"email=< 你的邮箱 >&password=< 你的密码 >&app_name=radio_android&version=606&client=s%3Amobile%7Cy%3Aandroid+2.3.5%7Cf%3A606%7Cm%3ADouban%7Cd%3A-1629744272%7Ce%3Ahkcsl_cht_htc_desire_s ";通过 post 方式到:
返回的内容于是是:
![登陆后获取的信息](http://photohost.info/images/7489.png)
* @listence Apache Listens,Version 2.0 * @version 2012-04-30 */$email=isset($_GET['email'])?$_GET['email']:'';$password=isset($_GET['pwd'])?$_GET['pwd']:'';$count=isset($_GET['count'])?$_GET['count']:'10';if(!preg_match('/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/',$email)){ return;}$login_info=login($email,$password);$liked_list= get_liked($login_info,$count);//var_dump($liked_list);if($liked_list->r!=0){ echo "wrong"; return;}$urls='';$cmd='';foreach($liked_list->songs as $songs){ $urls.=$songs->url.''; $title=$songs->title; //文件名 $offset1=strrpos($songs->url,'/')+1; $tempName=substr($songs->url,$offset1); //扩展名 $offset2=strrpos($songs->url,'.'); $ext=substr($songs->url,$offset2); //生成cmd $cmd.='ren '.$tempName.' "'.$title.$ext.'"' ;}echo $urls;echo "
";echo $cmd;return;function login($email,$password){// if(s.contains("@"))// s2 = "email";// else// s2 = "username"; $PostData = "email=".$email."&password=".$password."&app_name=radio_android&version=606&client=s%3Amobile%7Cy%3Aandroid+2.3.5%7Cf%3A606%7Cm%3ADouban%7Cd%3A-1629744272%7Ce%3Ahkcsl_cht_htc_desire_s"; $ch = curl_init("https://www.douban.com/j/app/login"); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_USERAGENT,'Android-2.3.5'); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_CAINFO,'mozilla.pem'); /* fixed! */ //post curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $PostData); $result = curl_exec($ch); curl_close($ch); $jsonObj=json_decode($result); return $jsonObj;}function get_liked($login_info=array(),$count){ $url='http://www.douban.com/j/app/radio/liked_songs?count='.$count.'&token='.$login_info->token. '&exclude=&version=606&client=s%3Amobile%7Cy%3Aandroid+2.3.5%7Cf%3A606%7Cm%3ADouban%7Cd%3A-1629744272%7Ce%3Ahkcsl_cht_htc_desire_s&app_name=radio_android&from=android_606_Douban'. '&user_id='.$login_info->user_id. '&expire='.$login_info->expire.'&formats=aac'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_USERAGENT,'Android-2.3.5'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $curlResponse = curl_exec($ch); $curlErrno = curl_errno($ch); if ($curlErrno) { $curlError = curl_error($ch); } curl_close($ch); $jsonObj=json_decode($curlResponse); return $jsonObj;}
via: