Как я могу аутентифицироваться на паровом сайте?

Я пытаюсь подключиться к паролю, используя следующий код.

Первый запрос с steamcommunity.com/login/getrsakey является успешным.

Запросите steamcommunity.com/login/dologin/ на steamcommunity.com/login/dologin/ все время выдает incorrect login.

Возможно, речь идет о шифровании пароля или необходимо добавить ssl.

Я использую для шифрования библиотеки на http://phpseclib.sourceforge.net/

 function geturl($url, $ref, $cookie, $postdata, $header, &$info, &$output) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36'); if ($ref) { curl_setopt($ch, CURLOPT_REFERER, $ref); } if ($cookie) { curl_setopt($ch, CURLOPT_COOKIE, $cookie); } if ($postdata) { curl_setopt($ch, CURLOPT_POST, true); $postStr = ""; foreach ($postdata as $key => $value) { if ($postStr) $postStr .= "&"; $postStr .= $key . "=" . $value; } curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr); } curl_setopt($ch, CURLOPT_HEADER, $header); $info = curl_getinfo($ch); $output = curl_exec($ch); curl_close($ch); } geturl("https://steamcommunity.com/login/getrsakey", null, null, array('username' => $login), 0, $info, $output); $data = json_decode($output, true); if ($data['success'] === true) { $publickey_exp = $data['publickey_exp']; $publickey_mod = $data['publickey_mod']; $RSA = new Crypt_RSA(); $RSA->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); $n = new Math_BigInteger($publickey_mod, 16); $e = new Math_BigInteger($publickey_exp, 16); $key = array("modulus"=>$n, "publicExponent"=>$e); $RSA->loadKey($key, CRYPT_RSA_PUBLIC_FORMAT_RAW); $encryptedPassword = base64_encode($RSA->encrypt($password, false)); $captchaGid = -1; $captchaText; $emailAuth; $emailSteamId; $params = array( 'username' => $login, 'password' => $encryptedPassword, 'rsatimestamp' => $data['timestamp'], 'captcha_gid' => $captchaGid, 'captcha_text' => $captchaText, 'emailauth' => $emailAuth, 'emailsteamid' => $emailSteamId ); geturl("https://steamcommunity.com/login/dologin/", null, null, $params, 0, $info, $output); $data = json_decode($output, true); var_dump($data); if ($data['captcha_needed']) { $captchaGid = $data['captcha_gid']; echo '<img src="https://steamcommunity.com/public/captcha.php?gid=' . $captchaGid . '">'; } } 

Я думаю, что было бы лучше использовать библиотеки третьей части для авторизации. Проверьте это: https://github.com/SmItH197/SteamAuthentication

Он создает кнопку входа в систему, например «Войти через Facebook».

EDIT: Steam имеет свой собственный API https://steamcommunity.com/dev

Я не могу быть уверен, но похоже, что вы пытаетесь зарегистрировать пользователя на своем сайте, используя Steam в качестве метода входа. Это то, что вы пытаетесь сделать? Если это так, я рекомендую использовать библиотеку LightOpenID .

 <?php require 'includes/lightopenid/openid.php'; $_STEAMAPI = "YOURSTEAMAPIKEY"; try { $openid = new LightOpenID('http://URL.TO.REDIRECT.TO.AFTER.LOGIN/'); if(!$openid->mode) { if(isset($_GET['login'])) { $openid->identity = 'http://steamcommunity.com/openid/?l=english'; // This is forcing english because it has a weird habit of selecting a random language otherwise header('Location: ' . $openid->authUrl()); } ?> <form action="?login" method="post"> <input type="image" src="http://img.ruphp.com/php/sits_small.png"> </form> <?php } elseif($openid->mode == 'cancel') { echo 'User has canceled authentication!'; } else { if($openid->validate()) { $id = $openid->identity; // identity is something like: http://steamcommunity.com/openid/id/76561197960435530 // we only care about the unique account ID at the end of the URL. $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/"; preg_match($ptn, $id, $matches); echo "User is logged in (steamID: $matches[1])\n"; // $matches[1] is the profile ID you will want to use for additional API calls } else { echo "User is not logged in.\n"; } } } catch(ErrorException $e) { echo $e->getMessage(); } ?> в <?php require 'includes/lightopenid/openid.php'; $_STEAMAPI = "YOURSTEAMAPIKEY"; try { $openid = new LightOpenID('http://URL.TO.REDIRECT.TO.AFTER.LOGIN/'); if(!$openid->mode) { if(isset($_GET['login'])) { $openid->identity = 'http://steamcommunity.com/openid/?l=english'; // This is forcing english because it has a weird habit of selecting a random language otherwise header('Location: ' . $openid->authUrl()); } ?> <form action="?login" method="post"> <input type="image" src="http://img.ruphp.com/php/sits_small.png"> </form> <?php } elseif($openid->mode == 'cancel') { echo 'User has canceled authentication!'; } else { if($openid->validate()) { $id = $openid->identity; // identity is something like: http://steamcommunity.com/openid/id/76561197960435530 // we only care about the unique account ID at the end of the URL. $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/"; preg_match($ptn, $id, $matches); echo "User is logged in (steamID: $matches[1])\n"; // $matches[1] is the profile ID you will want to use for additional API calls } else { echo "User is not logged in.\n"; } } } catch(ErrorException $e) { echo $e->getMessage(); } ?> 

В конце этого входа у вас будет ID профиля пользователя (т. 76561197960435530 ), который вы можете использовать во многих API, которые Steam предоставляет для сбора дополнительной информации о игроке.

Используйте функцию "urlencode()"

 $encryptedPassword = urlencode(base64_encode($RSA->encrypt($password, false)));