虾米自动签到 php,云签到之虾米音乐自动签到
依舊是1年前放在百度空間上的代碼,用的是蝦米音樂的wap端口簽到,話說這簽到代碼我用了至少2年了,蝦米也一直沒變過。。。
其實(shí)有了網(wǎng)易云音樂后已經(jīng)沒用過蝦米了,不過簽到一直有掛在服務(wù)器上,現(xiàn)在已經(jīng)簽了900多天了。。。
/*
*蝦米音樂簽到
*在代碼里填上你的用戶名和密碼~
*By Perfare(www.perfare.net)
*update 2014-3-23
*/
header("content-Type: text/html; charset=utf-8");
function curl_get($url, $use = false, $save = false, $referer = null, $post_data = null){
global $cookie_file;
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 2.3.5; zh-cn; MI-ONE Plus Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//需要使用cookies
if($use){
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
}
//需要保存cookies
if($save){
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
}
//需要referer偽裝
if(isset($referer))
curl_setopt($ch, CURLOPT_REFERER, $referer);
//需要post數(shù)據(jù)
if(is_array($post_data)) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
//簽到代碼
$user = '這里填上你的用戶名';//用戶名
$pwd = '這里填上你的密碼';//密碼
//登錄地址
$loginUrl = 'http://www.xiami.com/web/login';
//簽到頁面的地址
$signPageUrl = 'http://www.xiami.com/web';
//存放Cookies的文件
$cookie_file = tempnam('./temp','cookie');
//設(shè)置登錄需要提交的數(shù)據(jù)
$login_array=array(
'email'=>$user,
'password'=>$pwd,
'LoginButton'=>'登錄',
);
//直接提交數(shù)據(jù)(如果要驗(yàn)證碼也沒辦法了)
$res = curl_get($loginUrl, false, true, null, $login_array);
//訪問簽到頁面
$res = curl_get($signPageUrl, true, true);
//判斷今天是否已經(jīng)簽過到
if(strpos($res, '已連續(xù)簽到')){
preg_match('/
(.+)/i' , $res , $matches);$continueDays = ','.$matches[1];
$resultStr = "今天已簽過到".$continueDays;
}
else if(strpos($res, '每日簽到')){
//構(gòu)造提交簽到信息的URL
//用正則獲取check_in
preg_match('/每日簽到/i' , $res , $matches);
$signUrl = 'http://www.xiami.com'.$matches[1];
//提交簽到請(qǐng)求
$res = curl_get($signUrl, true, true, 'http://www.xiami.com/web');
//判斷是否簽到成功(再次訪問主頁)
$res = curl_get($signPageUrl, true, true);
if(strpos($res, '已連續(xù)簽到')){
preg_match('/
(.+)/i' , $res , $matches);$continueDays = ','.$matches[1];
$resultStr = "簽到成功".$continueDays;
}
else
$resultStr = '簽到失敗';
}
else
$resultStr = '登錄失敗,可能是需要驗(yàn)證碼';
echo $resultStr;
unlink($cookie_file);//刪除cookie文件
?>
總結(jié)
以上是生活随笔為你收集整理的虾米自动签到 php,云签到之虾米音乐自动签到的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 10、爬楼梯
- 下一篇: php7hugepage,HugePag