PHP快手直播弹幕采集,获取斗鱼弹幕php版(原创)

实例

error_reporting(0);

$config = array(

'roomId'=>$argv[1],//房间ID

'dmServerIp'=>gethostbyname('openbarrage.douyutv.com'),

'dmServerPort'=> 8601,//

'groupId'=>-9999,//据说目前填-9999就行不须获取gid了

'gidServerIp'=>'119.90.49.110',//119.90.49.111  119.90.49.104

'gidServerPort'=>8046,//8020

);

function checkRoomOnline($html){

$reg = '#"show_status":(\d*),#';

preg_match($reg,$html,$match);

if(count($match)==0){

return -1;

}

return $match[1];

}

function packMsg($str){

$length = pack('V', 4 + 4 + strlen($str) + 1);

$code = $length;

$magic = chr(0xb1).chr(0x02).chr(0x00).chr(0x00);

$end = chr(0x00);

return $length.$code.$magic.$str.$end;

}

function guid(){

mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.

$charid = strtoupper(md5(uniqid(rand(), true)));

$hyphen = chr(45);// "-"

$uuid = //chr(123)// "{"

substr($charid, 0, 8).$hyphen

.substr($charid, 8, 4).$hyphen

.substr($charid,12, 4).$hyphen

.substr($charid,16, 4).$hyphen

.substr($charid,20,12);

// .chr(125);// "}"

return $uuid;

}

function getGidMsg(){

global $config;

$time = time();

$uuid = str_replace('-','',guid());

$msg = 'type@=loginreq/

你可能感兴趣的:(PHP快手直播弹幕采集)