Skip to content

Commit baabbc9

Browse files
authored
Merge pull request #44 from jhl337/main
add: 支持领取Wegame新活动抽卡
2 parents 5718ebf + 2fe53f8 commit baabbc9

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

app/controller/Wegame.php

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,65 @@ private function getCookieValue($name)
231231
return $cookies[$name] ?? null;
232232
}
233233

234+
public function card()
235+
{
236+
$id = Request::param('id');
237+
$ticket = Request::param('ticket');
238+
if (!$id || !$ticket) {
239+
return Response::json(-1, '缺少参数');
240+
}
241+
$this->cookie = $this->cookie::fromArray([
242+
'tgp_id' => $id,
243+
'tgp_ticket' => $ticket,
244+
], '.wegame.com.cn');
245+
$response = $this->client->request('POST', 'https://www.wegame.com.cn/api/v1/wegame.pallas.dfm.DfmSocial/GetUserCards', [
246+
'cookies' => $this->cookie,
247+
'json' => [
248+
'from_src' => '三角洲行动',
249+
],
250+
'headers' => [
251+
'referer' => 'https://www.wegame.com.cn/helper/df/',
252+
],
253+
]);
254+
$result = $response->getBody()->getContents();
255+
$data = json_decode($result, true);
256+
if ($data['result']['error_code'] != 0) {
257+
return Response::json(-1, '获取卡牌信息失败');
258+
}
259+
if ($data['has_drawn_today']) {
260+
return Response::json(0, '今日已抽卡');
261+
}
262+
$response = $this->client->request('POST', 'https://www.wegame.com.cn/api/v1/wegame.pallas.dfm.DfmSocial/DrawCard', [
263+
'cookies' => $this->cookie,
264+
'json' => [
265+
'from_src' => '三角洲行动',
266+
],
267+
'headers' => [
268+
'referer' => 'https://www.wegame.com.cn/helper/df/',
269+
],
270+
]);
271+
$result = $response->getBody()->getContents();
272+
$data = json_decode($result, true);
273+
if ($data['result']['error_code'] != 0) {
274+
return Response::json(-1, '自动抽取卡牌失败');
275+
}
276+
$response = $this->client->request('POST', 'https://www.wegame.com.cn/api/v1/wegame.pallas.dfm.DfmSocial/GetCardsBestCombination', [
277+
'cookies' => $this->cookie,
278+
'json' => [
279+
'from_src' => '三角洲行动',
280+
],
281+
'headers' => [
282+
'referer' => 'https://www.wegame.com.cn/helper/df/',
283+
],
284+
]);
285+
$result = $response->getBody()->getContents();
286+
$data = json_decode($result, true);
287+
if ($data['result']['error_code'] != 0) {
288+
return Response::json(-1, '获取卡牌组合失败');
289+
}
290+
return Response::json(0, '获取成功', $data['cards']);
291+
}
292+
234293
public function gift()
235294
{
236295

@@ -404,4 +463,4 @@ private function findArrayMemberByName($array, $searchName) {
404463
}
405464
return '';
406465
}
407-
}
466+
}

route/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
Route::rule('access', 'Wegame/getWechatAccessToken');
3232
});
3333
Route::rule('gift', 'Wegame/gift');
34+
Route::rule('card', 'Wegame/card');
3435
});

0 commit comments

Comments
 (0)