Скажите, как можно сделать форму авторизации на сайте в программе, к примеру сайт вконтакте?
Этот топик читают: Гость
Ответов: 29
Рейтинг: 0
|
|||
карма: 1 |
|
Google
vip
|
#1.1контекстная реклама от партнеров
|
Гость
Ответов: 17029
Рейтинг: 0
|
|||
Редактировалось 3 раз(а), последний 2020-03-01 13:03:43 |
|||
карма: 0 |
|
Ответов: 29
Рейтинг: 0
|
|||
Много чего нашёл, но сути так и не понял, POST - запрос - как он работает, он заполняет поля name="..." и эмулирует нажатие на кнопку ?
Разве для авторизации на сайте нужно много чего отправлять кроме логина и пароля ? |
|||
карма: 1 |
|
Ответов: 1821
Рейтинг: 168
|
|||
VarNick, "на хлопський розум": POST запросы -- это данные, которые пользователь отсылает на сервер. За счет этого и работает закачка, получение данных, и т. д., и т.п...
VarNick писал(а): Разве для авторизации на сайте нужно много чего отправлять кроме логина и пароля ? |
|||
карма: 5 |
|
Ответов: 29
Рейтинг: 0
|
|||
sаmakacd писал(а): Это уже зависит от сайтаА может кто знает как создать авторизацию для сайта в контакте, там похоже скрипт сложным делает авторизацию, вот код: сайт <div id="pageBody" class="pageBody"> <div id="wrapH"> <div id="wrapHI"> <div id="header"><h1> Вход</h1></div> </div> </div> <div id="wrap2"> <div id="wrap1"> <div id="content"> <script type="text/javascript"> var vklogin = false; function try_to_login(obj, text) { if (text.substr(0, 4) == 'good') { var to = ''; if (location.hash.toString().length) { to += location.hash; } if (to.length) { window.location.href = '/' + to; } else { window.location.href = '/id' + text.substr(4); } } else if (text.substr(0, 10) == 'not_active') { window.location.href = '/login.php?r=1'; } else if (text.substr(0, 6) == 'invite') { window.location.href = '/help.php?page=welcome&hash=' + text.substr(6); } else if (text.substr(0, 9) == 'reginvite') { window.location.href = '/register.php?hash=' + text.substr(9); } else if (text.substr(0, 7) == 'vklogin') { vklogin = true; ge('login').submit(); } else { show('message_text'); ge('message_text').innerHTML = "<div id='error' style='font-size: 11px'>Указан неверный логин или пароль.</div>"; } } function quick_login() { var options = {onSuccess: try_to_login}; hide('message_text'); Ajax.postWithCaptcha('/login.php', {'op': 'a_login_attempt', 'login': ge('email').value}, options); } var captcha_send = 'Отправить'; var captcha_cancel = 'Отмена'; function showPhoneTT() { hideCodeTT(true); hidePhoneTT(true); animate(ge('fast_phone_tt'), window.is_rtl ? {opacity: 1, marginRight: 172} : {opacity: 1, marginLeft: 172}, 200); } function hideTT(el, fast) { if (fast === true) { var anim = data(el, 'tween'); if (anim) anim.stop(); setStyle(el, window.is_rtl ? {opacity: 0, marginRight: 182} : {opacity: 0, marginLeft: 182}); } else { animate(el, {opacity: 0}, 200, hidePhoneTT.pbind(true)); } } function hidePhoneTT(fast) { hideTT(ge('fast_phone_tt'), fast); } function showCodeTT() { hideCodeTT(true); hidePhoneTT(true); animate(ge('fast_code_tt'), window.is_rtl ? {opacity: 1, marginRight: 172} : {opacity: 1, marginLeft: 172}, 200); } function hideCodeTT(fast) { hideTT(ge('fast_code_tt'), fast); } var sentPhone = false, restoreCode = false; function fastRestoreCheck() { if (sentPhone !== false) { if (ge('fast_restore_phone').value == sentPhone) { show(ge('fast_restore_code_row')); } else { hide(ge('fast_restore_code_row')); } } } function fastRestore(ev) { ev = ev || window.event; if (ev && (ev.keyCode !== undefined) && (ev.type != 'click')) { if (ev.keyCode !== KEY.ENTER) { return; } if (ev.target == ge('fast_restore_phone') && isVisible(ge('fast_restore_code_row'))) { focusAtEnd(ge('fast_restore_code')); return cancelEvent(ev); } } var btn = ge('fast_restore_btn'), phone = ge('fast_restore_phone').value, code; if (phone.replace(/[^0-9]/g, '').length < 8) { focusAtEnd(ge('fast_restore_phone')); notaBene(ge('fast_restore_phone')); return cancelEvent(ev); } lockButton(btn); if (isVisible(ge('fast_restore_code_row'))) { code = ge('fast_restore_code').value; if (code.replace(/[^0-9a-z]/g, '').length < 4) { focusAtEnd(ge('fast_restore_code')); notaBene(ge('fast_restore_code')); return cancelEvent(ev); } Ajax.postWithCaptcha('login.php', {act: 'fast_restore_code', phone: phone, code: code, restore: restoreCode}, { onSuccess: function(obj, text) { var res = eval('(' + text + ')'); unlockButton(btn); var err = ge('fast_restore_error'); if (res.error) { err.innerHTML = res.error; if (!isVisible(err)) { show(err); } else { animate(err, {backgroundColor: '#F4EBBD'}, 100, animate.pbind(err, {backgroundColor: '#F9F6E7'}, 2000)); } notaBene(ge('fast_restore_code')); } else if (res.success) { location.href = 'https://login.vk.com/?act=fast_restored&code=' + restoreCode + '&_origin=' + encodeURIComponent(location.protocol + '//' + location.host); } }, onCaptchaShow: function() { unlockButton(btn); } }); } else { Ajax.postWithCaptcha('login.php', {act: 'fast_restore', phone: phone, hash: 'dcb495193e8e634cef'}, { onSuccess: function(obj, text) { var res = eval('(' + text + ')'); if (res.reload) { location.reload(true); return; } if (res.wait) { setTimeout(fastRestore.pbind(false), 1000); return; } unlockButton(btn); var err = ge('fast_restore_error'); if (res.error) { err.innerHTML = res.error; if (!isVisible(err)) { show(err); } else { animate(err, {backgroundColor: '#F4EBBD'}, 100, animate.pbind(err, {backgroundColor: '#F9F6E7'}, 2000)); } notaBene(ge('fast_restore_phone')); } else { restoreCode = res.restore; hide(err); sentPhone = phone; show(ge('fast_restore_code_row')); setTimeout(focusAtEnd.pbind(ge('fast_restore_code')), 0); } }, onCaptchaShow: function() { unlockButton(btn); } }); } return cancelEvent(ev); } </script> <div id="message_text"> </div> <div class="simplePage" style="padding: 15px 0px 0px"> <form method="post" name="login" id="login" action="https://login.vk.com/" onsubmit="if (vklogin) { return true} else { quick_login();return false;}"> <input name="act" id="act" value="login" type="hidden"> <input name="to" id="to" value="" type="hidden"> <input name="_origin" value="http://vk.com" type="hidden"> <input name="ip_h" value="25b8adc5f7dafb63dd" type="hidden"> <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%"> <tbody><tr> <td class="ta_r log_label"><span class="grey">Телефон или e-mail:</span></td> <td style="padding: 0px"> <input class="inputText" name="email" value="" id="email" style="width: 152px; margin: 0px" type="text"> </td><td> </td></tr> <tr> <td class="ta_r log_label"><span class="grey">Пароль:</span></td> <td style="padding: 0px"> <input class="inputText" name="pass" value="" id="pass" style="width: 152px; margin: 0px" type="password"> </td> </tr> <tr> <td class="ta_r log_label"> </td> <td> <div style="width: 150px;" class="checkbox_container" id="container1"><table cellpadding="0" cellspacing="0"><tbody><tr><td class="checkbox"><div class="checkbox_off"></div></td><td class="checkbox_label">Чужой компьютер<input name="expire" id="expire" value="" type="hidden"></td></tr></tbody></table></div> <script type="text/javascript"> onDomReady(function() { new Checkbox(ge('expire'), { width: 150, label: 'Чужой компьютер' }); focusAtEnd(ge('email').value ? ge('pass') : ge('email')); if (ge('fast_restore_btn')) { ge('fast_restore_btn').parentNode.appendChild(ce('div', {innerHTML: '<iframe name="fast_restore_test_frame"></iframe><form id="fast_restore_test_form" method="POST" action="https://login.vk.com/?act=create_test&_origin=http://vk.com&' + Math.random() + '" target="fast_restore_test_frame"></form>'}, {position: 'absolute', visibility: 'hidden'})); ge('fast_restore_test_form').submit(); } }); </script> </td> </tr> <tr> <td class="ta_r log_label"> </td> <td><div style="height:20px; margin:5px 0px"> <div class="button_blue"><button onclick="quick_login();return cancelEvent(event);">Войти</button></div><span class="divide"> </span><div class="button_blue"><a href="/join" class="button_link"><button onclick="location.href='/join';return cancelEvent(event);">Регистрация</button></a></div> </div></td> </tr> </tbody></table> <input value="." style="color:#fff;border:0;padding:0;margin:0;background:#fff;height:6px;width:6px" type="submit"> </form> <div class="login_restore"> <table border="0" cellpadding="0" cellspacing="0" align="center" width="100%"> <tbody><tr><td class="ta_r log_label"> </td><td><a href="/restore">Забыли пароль или не можете войти?</a></td></tr> </tbody></table> </div> </div> </div> </div> </div> </div> А вот мой бред который пытаюсь довести до ума, может кто нить подскажет как правильно сделать? code_29805.txt |
|||
карма: 1 |
| ||
файлы: 1 | code_29805.txt [2.4KB] [355] |
Ответов: 5446
Рейтинг: 323
|
|||
VarNick, в контактике самая запутанная система авторизации без HTTPS, которую я когда-либо видел. Там походу половина работы делается javascript-ами, за:censored:ся разбирать. Для легальных целей есть отдельное API.
|
|||
карма: 1 |
|
6