Advertisement
Guest User

voc.php

a guest
Nov 17th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2. function req($url, $token = null, $data = null, $pin = null){
  3. $header[] = "Host: api.gojekapi.com";
  4. $header[] = "User-Agent: okhttp/3.12.1";
  5. $header[] = "Accept: application/json";
  6. $header[] = "Accept-Language: en-ID";
  7. $header[] = "Content-Type: application/json; charset=UTF-8";
  8. $header[] = "X-AppVersion: 3.34.1";
  9. $header[] = "X-UniqueId: ".time()."57".mt_rand(1000,9999);
  10. $header[] = "Connection: keep-alive";
  11. $header[] = "X-User-Locale: en_ID";
  12. //$header[] = "X-Location: -6.3894201,106.0794195";
  13. //$header[] = "X-Location-Accuracy: 3.0";
  14. if ($pin):
  15. $header[] = "pin: $pin";
  16. endif;
  17. if ($token):
  18. $header[] = "Authorization: Bearer $token";
  19. endif;
  20. $c = curl_init("https://api.gojekapi.com".$url);
  21. curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
  22. curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  23. if ($data):
  24. curl_setopt($c, CURLOPT_POSTFIELDS, $data);
  25. curl_setopt($c, CURLOPT_POST, true);
  26. endif;
  27. curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
  28. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  29. curl_setopt($c, CURLOPT_HEADER, true);
  30. curl_setopt($c, CURLOPT_HTTPHEADER, $header);
  31. $response = curl_exec($c);
  32. $httpcode = curl_getinfo($c);
  33. if (!$httpcode)
  34. return false;
  35. else {
  36. $header = substr($response, 0, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  37. $body = substr($response, curl_getinfo($c, CURLINFO_HEADER_SIZE));
  38. }
  39. $json = json_decode($body, true);
  40. return $json;
  41. }
  42. function save($filename, $content)
  43. {
  44. $save = fopen($filename, "a");
  45. fputs($save, "$content\r\n");
  46. fclose($save);
  47. }
  48. function cek($token)
  49. {
  50. $claim = req("/gopoints/v3/wallet/vouchers?limit=10&page=1", $token, null);
  51. if ($claim['success'] == 1)
  52. {
  53. return $claim;
  54. }
  55. else
  56. {
  57. save("error_log.txt", json_encode($claim));
  58. return false;
  59. }
  60. }
  61. echo 'Enter Token : ';
  62. $otp = trim(fgets(STDIN));
  63. $iki = cek($otp);
  64. foreach ($iki['data'] as $items) {
  65. echo $items['title'].PHP_EOL;
  66. echo $items['expiry_date'].PHP_EOL;
  67. echo $items['configs'][0]['key'].' '.$items['configs'][0]['value'].PHP_EOL;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement