Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. <?php
  2. function request($url, $post = null, $cookies = null, $headers = null)
  3. {
  4. $ch = curl_init();
  5. curl_setopt($ch, CURLOPT_URL, $url);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  7. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  8. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  9. curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
  10. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  11. curl_setopt($ch, CURLOPT_HEADER, 1);
  12. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:62.0) Gecko/20100101 Firefox/62.0');
  13. if (! is_null($headers))
  14. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  15. if (! is_null($cookies))
  16. curl_setopt($ch, CURLOPT_COOKIE, $cookies);
  17. if (!is_null($post)){
  18. curl_setopt($ch, CURLOPT_POST, 1);
  19. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  20. }
  21. $resp = curl_exec($ch);
  22. $header_len = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  23. $header = substr($resp, 0, $header_len);
  24. $body = substr($resp, $header_len);
  25. curl_close($ch);
  26. preg_match_all('#Set-Cookie: ([^;]+)#', $header, $d);$cookie = '';
  27. for ($o=0;$o<count($d[0]);$o++) {
  28. $cookie.=$d[1][$o].";";
  29. }
  30.  
  31. return [$header, $body, $cookie];
  32. }
  33. $headerd = array(
  34. 'Connection: keep-alive',
  35. 'Accept: application/json, text/javascript',
  36. 'Auth0-Client: eyJuYW1lIjoiYXV0aDAuanMiLCJ2ZXJzaW9uIjoiNi44LjQifQ',
  37. 'User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Redmi 3S Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 Mobile Safari/537.36
  38. ',
  39. 'Content-Type: application/x-www-form-urlencoded',
  40. 'Accept-Encoding: gzip, deflate',
  41. 'Accept-Language: id-ID,en-US;q=0.9',
  42. 'X-Requested-With: com.telkomsel.telkomselcm'
  43. );
  44. //submit otp
  45. $d = request('https://tdwidm.telkomsel.com/oauth/ro', 'scope=openid+offline_access&response_type=token&sso=false&device=a91e911fa22f2175352511530830796a%3AMozilla%2F5.0+(Windows+NT+10.0%3B+WOW64%3B+rv%3A62.0)+Gecko%2F20100101+Firefox%2F62.0&connection=sms&username=%2B'.$_GET['nomor'].'&password='.$_GET['otp'].'&client_id=Xlj9pkfK6yYumf6G8KE2S5TDWgTtczb0&grant_type=password', null, $headerd);
  46. $token = $d[1];
  47. preg_match('#{"id_token":"(.+?)"#', $token, $tokenpecah);
  48. $token = $tokenpecah[1];
  49. echo $token;
  50. //print_r($d);
  51. //get info pake token
  52. //$e = request('https://tdwidm.telkomsel.com/tokeninfo', 'id_token='.$token.'', null, $headerd);
  53. //print_r($e);
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement