$room_id, 'raffle_id' => $guard['id'], 'raffle_name' => $raffle_name, 'wait' => time() ]; Statistics::addPushList(self::ACTIVE_TITLE); array_push(self::$wait_list, $data); } return true; } /** * @use 创建抽奖任务 * @param array $raffles * @return array */ protected static function createLottery(array $raffles): array { $url = 'https://api.live.bilibili.com/xlive/lottery-interface/v3/guard/join'; $tasks = []; $results = []; $user_info = User::parseCookies(); foreach ($raffles as $raffle) { $payload = [ 'id' => $raffle['raffle_id'], 'roomid' => $raffle['room_id'], "type" => "guard", 'csrf_token' => $user_info['token'], 'csrf' => $user_info['token'], 'visit_id' => '' ]; array_push($tasks, [ 'payload' => Sign::api($payload), 'source' => [ 'room_id' => $raffle['room_id'], 'raffle_id' => $raffle['raffle_id'] ] ]); } $results = Curl::asyncPost($url, $tasks); # print_r($results); return $results; } /** * @use 解析抽奖信息 * @param array $results * @return mixed|void */ protected static function parseLottery(array $results) { foreach ($results as $result) { $data = $result['source']; $content = $result['content']; $de_raw = json_decode($content, true); if (isset($de_raw['code']) && $de_raw['code'] == 0) { Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . self::ACTIVE_TITLE . ": " . $de_raw['data']['award_name'] . "x" . $de_raw['data']['award_num']); Statistics::addSuccessList(self::ACTIVE_TITLE); } else { Log::notice("房间 {$data['room_id']} 编号 {$data['raffle_id']} " . self::ACTIVE_TITLE . ": {$de_raw['msg']}"); } } } }