BiliHelper-personal/src/Api/Esports/ApiGuess.php
2024-12-31 11:17:17 +08:00

78 lines
2.4 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2018 ~ 2026
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、 。
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ヽ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
namespace Bhp\Api\Esports;
use Bhp\Request\Request;
use Bhp\User\User;
class ApiGuess
{
/**
* 获取赛事竞猜
* @param int $pn
* @param int $ps
* @return array
*/
public static function collectionQuestion(int $pn, int $ps = 50): array
{
$url = 'https://api.bilibili.com/x/esports/guess/collection/question';
$payload = [
'pn' => $pn,
'ps' => $ps,
'stime' => date("Y-m-d H:i:s", strtotime(date("Y-m-d", time()))),
'etime' => date("Y-m-d H:i:s", strtotime(date("Y-m-d", time())) + 86400 - 1)
];
$headers = [
'origin' => 'https://www.bilibili.com',
'referer' => 'https://www.bilibili.com/v/game/match/competition',
];
return Request::getjSON(true, 'pc', $url, $payload, $headers);
}
/**
* 竞猜
* @param int $oid
* @param int $main_id
* @param int $detail_id
* @param int $count
* @return array
*/
public static function guessAdd(int $oid, int $main_id, int $detail_id, int $count): array
{
$user = User::parseCookie();
//
$url = 'https://api.bilibili.com/x/esports/guess/add';
$payload = [
'oid' => $oid,
'main_id' => $main_id,
'detail_id' => $detail_id,
'count' => $count,
'is_fav' => 0,
'csrf' => $user['csrf'],
'csrf_token' => $user['csrf'],
];
$headers = [
'origin' => 'https://www.bilibili.com',
'referer' => 'https://www.bilibili.com/v/game/match/competition'
];
return Request::postJson(true, 'pc', $url, $payload, $headers);
}
}