· 6 years ago · Oct 30, 2019, 02:50 PM
1<?php
2
3$headers = array();
4 $headers[] = "Host: api.gojekapi.com";
5 $headers[] = "User-Agent: okhttp/3.10.0";
6 $headers[] = "Accept: application/json";
7 $headers[] = "Accept-Language: en-ID";
8 $headers[] = 'Content-Type: application/json';
9 $headers[] = 'X-AppVersion: 3.27.0';
10 $headers[] = "X-Uniqueid: ac94e5d0e7f3f".rand(111,999);
11 $headers[] = 'X-Location: -6.405821,106.064193';
12
13function curl($url, $fields = null, $headers = null){
14
15 $ch = curl_init();
16 curl_setopt($ch, CURLOPT_URL, "https://api.gojekapi.com".$url);
17 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
18 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
19 if ($fields !== null) {
20 curl_setopt($ch, CURLOPT_POST, 1);
21 curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
22 }
23if ($headers !== null) {
24 curl_setopt($ch, CURLOPT_HEADER, true);
25 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
26}
27curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
28 $result = curl_exec($ch);
29 $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
30 curl_close($ch);
31
32 return array(
33 $result,
34 $httpcode
35 );
36}
37
38function nama(){
39 $ch = curl_init();
40 curl_setopt($ch, CURLOPT_URL, "http://ninjaname.horseridersupply.com/indonesian_name.php");
41 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
42 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
43 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
44 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
45 $ex = curl_exec($ch);
46 // $rand = json_decode($rnd_get, true);
47 preg_match_all('~(• (.*?)<br/>• )~', $ex, $name);
48 //echo json_encode($name);
49 return $name[2][mt_rand(0, 14) ];
50}
51
52function save($filename, $content)
53{
54 $save = fopen($filename, "a");
55 fputs($save, "$content\r\n");
56 fclose($save);
57}
58
59//echo "Masukkan No HP :";
60$nomor = trim(fgets(STDIN));
61
62 $nama = nama();
63 $email = str_replace(" ", "", $nama) . mt_rand(100, 999);
64
65 $d['name'] = $nama;
66 $d['email'] = $email . '@gmail.com';
67 $d['phone'] = '+'.$nomor;
68
69 $data = json_encode($d);
70 $tempik = curl("/v5/customers", $data, $headers);
71 //$hasilreg = json_encode($tempik[0]);
72 $hasilreg = end(explode("\n", $tempik[0]));
73 $data_reg = json_decode($hasilreg);
74 print_r($data_reg);