$room_id, 'raffle_id' => $gift['raffleId'], 'title' => $gift['title'], 'type' => $gift['type'], 'wait' => $gift['time_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 { // V3接口 暂做保留处理 // $url = 'https://api.live.bilibili.com/gift/v3/smalltv/join'; // $url = 'https://api.live.bilibili.com/gift/v4/smalltv/getAward'; $url = 'https://api.live.bilibili.com/xlive/lottery-interface/v5/smalltv/join'; $tasks = []; $results = []; $user_info = User::parseCookies(); foreach ($raffles as $raffle) { $payload = [ 'id' => $raffle['raffle_id'], 'roomid' => $raffle['room_id'], 'type' => $raffle['type'], 'csrf_token' => $user_info['token'], 'csrf' => $user_info['token'], 'visit_id' => '' ]; array_push($tasks, [ 'payload' => Sign::common($payload), 'source' => [ 'room_id' => $raffle['room_id'], 'raffle_id' => $raffle['raffle_id'] ] ]); } $results = Curl::async('app', $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']) { // 推送中奖信息 if ($de_raw['data']['award_name'] != '辣条' && $de_raw['data']['award_name'] != '') { $info = $de_raw['data']['award_name'] . 'x' . $de_raw['data']['award_num']; Notice::push('gift', $info); } 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']}"); } } } }