Advertisement
OwniiEU

Untitled

Mar 9th, 2015
2,709
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.10 KB | None | 0 0
  1. <?
  2.  
  3.     define("PSN_AUTHORIZE","https://auth.api.sonyentertainmentnetwork.com/2.0/oauth/authorize?response_type=code&client_id=78420c74-1fdf-4575-b43f-eb94c7d770bf&redirect_uri=https%3a%2f%2fwww.bungie.net%2fen%2fUser%2fSignIn%2fPsnid&scope=psn:s2s&request_locale=en");
  4.     define("PSN_LOGIN","https://auth.api.sonyentertainmentnetwork.com/login.do");
  5.  
  6.     function do_curl($url, $cookies = Array(), $post = Array(), $redirect = false)
  7.     {
  8.         $ch = curl_init($url);
  9.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  10.         curl_setopt($ch, CURLOPT_HEADER, true);
  11.        
  12.  
  13.  
  14.         if( count($cookies) > 0 )
  15.         {
  16.             $sCookies = "";
  17.             foreach($cookies AS $k => $v)
  18.             {
  19.                 $sCookies .= $k."=".$v."&";
  20.             }
  21.  
  22.             rtrim($sCookies,"&");
  23.             curl_setopt($ch, CURLOPT_COOKIE, $sCookies);
  24.         }
  25.        
  26.  
  27.         if( count($post) > 0 )
  28.         {
  29.             $sPosts = "";
  30.             foreach($post AS $k => $v)
  31.             {
  32.                 $sPost .= $k."=".$v."&";
  33.             }
  34.  
  35.             rtrim($sPost,"&");
  36.             curl_setopt($ch, CURLOPT_POST, count($post));
  37.             curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
  38.         }
  39.  
  40.         $result = curl_exec($ch);
  41.         echo '<pre>result: '.$result.'</pre>';
  42.         // get cookie
  43.         preg_match('/^Set-Cookie:\s*([^;]*)/mi', $result, $m);
  44.  
  45.         parse_str($m[1], $cookies);
  46.  
  47.         if( $redirect )
  48.         {
  49.             return curl_getinfo($ch);
  50.         }
  51.  
  52.         curl_close($ch);
  53.  
  54.         return $cookies;
  55.  
  56.     }
  57.  
  58.     $jsessionid = do_curl(PSN_AUTHORIZE)['JSESSIONID'];
  59.  
  60.     $njsessionid = do_curl(PSN_LOGIN, Array("JSESSIONID" => $jsessionid), Array("j_username" => urlencode("my@email.com"), "j_password" => urlencode("mypasswordissave")))['JSESSIONID'];
  61.  
  62.     $bungiesignin = do_curl(PSN_AUTHORIZE, Array("JSESSIONID" => $njsessionid), Array(), true);
  63.  
  64.     //var_dump($bungiesignin);
  65.  
  66. ?>
  67.  
  68. // OUTPUT:
  69.  
  70. result: HTTP/1.1 302 Found
  71. Location: https://auth.api.sonyentertainmentnetwork.com/login.jsp?request_locale=en_US&request_theme=liquid
  72. Date: Mon, 09 Mar 2015 18:03:38 GMT
  73. Server: Apache
  74. P3P: CP="This site does not have a P3P policy."
  75. Content-Length: 0
  76. Content-Type: text/plain; charset=UTF-8
  77. Set-Cookie: JSESSIONID=BCB6F3CDD016E8E2674D310550A9A58B.lvp-p1-npversat26-4809; path=/; HttpOnly; secure
  78.  
  79. result: HTTP/1.1 302 Found
  80. Location: https://auth.api.sonyentertainmentnetwork.com/loginSuccess.jsp
  81. Date: Mon, 09 Mar 2015 18:03:38 GMT
  82. Server: Apache
  83. Content-Length: 0
  84. Content-Type: text/plain; charset=UTF-8
  85. Set-Cookie: JSESSIONID=60EE588F3E946AC798B38D27A84EB1A4.lvp-p1-npversat05-4709; path=/; HttpOnly; secure
  86.  
  87. result: HTTP/1.1 302 Found
  88. Location: https://auth.api.sonyentertainmentnetwork.com/login.jsp?request_locale=en_US&request_theme=liquid
  89. Date: Mon, 09 Mar 2015 18:03:39 GMT
  90. Server: Apache
  91. P3P: CP="This site does not have a P3P policy."
  92. Content-Length: 0
  93. Content-Type: text/plain; charset=UTF-8
  94. Set-Cookie: JSESSIONID=B55459F623A2AAE3110DFBFBCCE3C7D3.lvp-p1-npversat13-4809; path=/; HttpOnly; secure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement