-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathPin.php
130 lines (119 loc) · 4.49 KB
/
Pin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
namespace App\newFUT;
//Laravel Providers
use Illuminate\Support\Facades\Log;
//Custom Providers
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
class Pin {
use Config;
public function __construct($sku = false, $sid = '', $nucleus_id = 0, $persona_id = '', $dob = false, $platform = false) {
//account
$this->sid = $sid;
$this->nucleus_id = $nucleus_id;
$this->persona_id = $persona_id;
$this->dob = $dob;
$this->platform = $platform;
//pinvars
$response = (new Client)->get("https://www.easports.com/fifa/ultimate-team/web-app/js/compiled_1.js")->getBody();
$this->sku = $m[preg_match('/enums.SKU.FUT="(.+?)"/', $response, $m)];
$this->taxv = $m[preg_match('/PinManager.TAXONOMY_VERSION=([0-9\.]+)/', $response, $m)];
$this->tidt = $m[preg_match('/PinManager.TITLE_ID_TYPE="(.+?)"/', $response, $m)];
$this->rel = $m[preg_match('/rel:"(.+?)"/', $response, $m)];
$this->gid = $m[preg_match('/gid:([0-9]+?)/', $response, $m)];
$this->plat = $m[preg_match('/plat:"(.+?)"/', $response, $m)];
$this->et = $m[preg_match('/et:"(.+?)"/', $response, $m)];
$this->pidt = $m[preg_match('/pidt:"(.+?)"/', $response, $m)];
//headers
$this->headers = [
'Origin' => 'https://www.easports.com',
'Referer' => 'https://www.easports.com/fifa/ultimate-team/web-app/',
'x-ea-game-id' => $this->sku,
'x-ea-game-id-type' => $this->tidt,
'x-ea-taxv' => $this->taxv
];
$this->custom = [
'networkAccess' => 'W',
'service_plat' => substr($platform, 0, 3)
];
$this->s = 2;
}
private function __ts() {
return date('Y-m-dTH:i:s').'.'.date('v').'Z';
}
public function event($en, $pgid = false, $status = false, $source = false, $end_reason = false) {
$data = [
'core' => [
's' => $this->s,
'pidt' => $this->pidt,
'pid' => $this->persona_id,
'pidm' => [
'nucleus' => $this->nucleus_id
],
'didm' => [
'uuid' => '0'
],
'ts_event' => $this->__ts(),
'en' => $en
]
];
if(isset($this->dob)) {
$data['core']['dob'] = $this->dob;
}
if($pgid) {
$data['pgid'] = $pgid;
}
if($status) {
$data['status'] = $status;
}
if($source) {
$data['source'] = $source;
}
if($end_reason) {
$data['end_reason'] = $end_reason;
}
if($en == 'login') {
$data['type'] = "utas";
$data['userid'] = $this->persona_id;
} elseif($en == 'page_view') {
$data['type'] = "menu";
} elseif($en == 'error') {
$data['server_type'] = 'utas';
$data['errid'] = 'server_error';
$data['type'] = 'disconnect';
$data['sid'] = $this->sid;
}
$this->s += 1;
return $data;
}
public function send($events) {
$response = (new Client)->request('POST', $this->pin_url, [
'body' => json_encode([
'taxv' => $this->taxv,
'tidt' => $this->tidt,
'tid' => $this->sku,
'rel' => $this->rel,
'v' => $this->v,
'ts_post' => $this->__ts(),
'sid' => $this->sid,
'gid' => $this->gid,
'plat' => $this->plat,
'et' => $this->et,
'loc' => 'en_US',
'is_sess' => (isset($this->sid) ? true : false),
'custom' => $this->custom,
'events' => $events
]),
'headers' => $this->headers,
'http_errors' => false
]);
$body = json_decode($response->getBody(true), true);
if($body['status'] !== 'ok') {
throw new FutError("PinEvent is NOT OK, probably they changed something.", 0, null, [
"reason" => "pin_event"
]);
}
return true;
}
}
?>