基于PHP实现的bilibili直播签到

PHP 小白教程

285 0

准备工作

  1. 运行php的环境
  2. B站登录状态的cookie

源码

<?php

# 这是你要填的
$cookie="";

# 下面基本不用动
$url="https://api.live.bilibili.com/sign/doSign";
$curl = curl_init();
$ip_long = array(
       array('607649792', '608174079'), //36.56.0.0-36.63.255.255
       array('1038614528', '1039007743'), //61.232.0.0-61.237.255.255
       array('1783627776', '1784676351'), //106.80.0.0-106.95.255.255
       array('2035023872', '2035154943'), //121.76.0.0-121.77.255.255
       array('2078801920', '2079064063'), //123.232.0.0-123.235.255.255
       array('-1950089216', '-1948778497'), //139.196.0.0-139.215.255.255
       array('-1425539072', '-1425014785'), //171.8.0.0-171.15.255.255
       array('-1236271104', '-1235419137'), //182.80.0.0-182.92.255.255
       array('-770113536', '-768606209'), //210.25.0.0-210.47.255.255
       array('-569376768', '-564133889'), //222.16.0.0-222.95.255.255
   );
$rand_key = mt_rand(0, 9);
$ip= long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
$header = array('User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36',
'Accept-Encoding: gzip, deflate',
'Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
'cookie:'.$cookie,
'CLIENT-IP:'.$ip,
'X-FORWARDED-FOR:'.$ip);
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
//curl_setopt($curl,CURLOPT_HTTPHEADER,['X-FORWARDED-FOR:164.89.81.12','CLIENT-IP:164.89.81.12']);
curl_setopt($curl,CURLOPT_REFERER,'');
curl_setopt($curl,CURLOPT_USERAGENT,'okhttp/3.8.1');
$json=curl_exec($curl);
curl_close($curl);
$html=json_decode($json,true);
switch($html['code']){
case "-101":
echo '账号未登录';
break;
case "0":
echo '哔哩哔哩直播签到成功';
break;
case "1011040":
echo '今日已签到过,无法重复签到';
break;
}

参考资料:1

这家伙太懒了,什么也没留下。
最新回复 (0)
    • 1OVE论坛 - YiOVE
      2
        登录 注册
返回