-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathfunction.php
More file actions
139 lines (137 loc) · 4.02 KB
/
function.php
File metadata and controls
139 lines (137 loc) · 4.02 KB
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
131
132
133
134
135
136
137
138
139
<?php
function request($url, $token = null, $data = null, $pin = null, $location = null){
$header[] = "Host: api.gojekapi.com";
$header[] = "User-Agent: okhttp/3.12.1";
$header[] = "Accept: application/json";
$header[] = "Accept-Language: en-ID";
$header[] = "Content-Type: application/json; charset=UTF-8";
$header[] = "X-AppVersion: 3.48.2";
$header[] = "X-UniqueId: ".time()."57".mt_rand(1000,9999);
$header[] = "Connection: keep-alive";
$header[] = "X-User-Locale: en_ID";
if ($location):
$header[] = "X-Location: $location";
if ($pin):
$header[] = "pin: $pin";
endif;
if ($token):
$header[] = "Authorization: Bearer $token";
endif;
$c = curl_init("https://api.gojekapi.com".$url);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
if ($data):
curl_setopt($c, CURLOPT_POSTFIELDS, $data);
curl_setopt($c, CURLOPT_POST, true);
endif;
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_HEADER, true);
curl_setopt($c, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($c);
$httpcode = curl_getinfo($c);
if (!$httpcode)
return false;
else {
$header = substr($response, 0, curl_getinfo($c, CURLINFO_HEADER_SIZE));
$body = substr($response, curl_getinfo($c, CURLINFO_HEADER_SIZE));
}
$json = json_decode($body, true);
return $json;
}
function save($filename, $content)
{
$save = fopen($filename, "a");
fputs($save, "$content\r\n");
fclose($save);
}
function nama()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ninjaname.horseridersupply.com/indonesian_name.php");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$ex = curl_exec($ch);
// $rand = json_decode($rnd_get, true);
preg_match_all('~(• (.*?)<br/>• )~', $ex, $name);
return $name[2][mt_rand(0, 14) ];
}
function register($no)
{
$nama = nama();
$email = str_replace(" ", "", $nama) . mt_rand(100, 999);
$data = '{"name":"' . $nama . '","email":"' . $email . '@gmail.com","phone":"+' . $no . '","signed_up_country":"ID"}';
$register = request("/v5/customers", "", $data);
//print_r($register);
if ($register['success'] == 1)
{
return $register['data']['otp_token'];
}
else
{
save("error_log.txt", json_encode($register));
return false;
}
}
function verif($otp, $token)
{
$data = '{"client_name":"gojek:cons:android","data":{"otp":"' . $otp . '","otp_token":"' . $token . '"},"client_secret":"83415d06-ec4e-11e6-a41b-6c40088ab51e"}';
$verif = request("/v5/customers/phone/verify", "", $data);
if ($verif['success'] == 1)
{
return $verif['data']['access_token'];
}
else
{
save("error_log.txt", json_encode($verif));
return false;
}
}
function login($no)
{
$nama = nama();
$email = str_replace(" ", "", $nama) . mt_rand(100, 999);
$data = '{"phone":"+'.$no.'"}';
$register = request("/v4/customers/login_with_phone", "", $data);
//print_r($register);
if ($register['success'] == 1)
{
return $register['data']['login_token'];
}
else
{
save("error_log.txt", json_encode($register));
return false;
}
}
function veriflogin($otp, $token)
{
$data = '{"client_name":"gojek:cons:android","client_secret":"83415d06-ec4e-11e6-a41b-6c40088ab51e","data":{"otp":"'.$otp.'","otp_token":"'.$token.'"},"grant_type":"otp","scopes":"gojek:customer:transaction gojek:customer:readonly"}';
$verif = request("/v4/customers/login/verify", "", $data);
if ($verif['success'] == 1)
{
return $verif['data']['access_token'];
}
else
{
save("error_log.txt", json_encode($verif));
return false;
}
}
function claim($token)
{
$data = '{"promo_code":"GOFOODHEMAT1"}';
$claim = request("/go-promotions/v1/promotions/enrollments", $token, $data);
if ($claim['success'] == 1)
{
return $claim['data']['message'];
}
else
{
save("error_log.txt", json_encode($claim));
return false;
}
}
?>