【移動應(yīng)用開發(fā)技術(shù)】二維碼登錄的原理是什么_第1頁
【移動應(yīng)用開發(fā)技術(shù)】二維碼登錄的原理是什么_第2頁
【移動應(yīng)用開發(fā)技術(shù)】二維碼登錄的原理是什么_第3頁
【移動應(yīng)用開發(fā)技術(shù)】二維碼登錄的原理是什么_第4頁
【移動應(yīng)用開發(fā)技術(shù)】二維碼登錄的原理是什么_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

【移動應(yīng)用開發(fā)技術(shù)】二維碼登錄的原理是什么

二維碼登錄的原理是什么?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面在下將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。首先說下整個授權(quán)流程:在客戶端網(wǎng)頁中會不斷向服務(wù)器發(fā)送https連接,并且這里傳輸很少的數(shù)據(jù)之后就斷開連接了,下面看下微信網(wǎng)頁中這個login1c709c.js文件:(function($,

_aoWin)

{

_aoWin.QRLogin

=

{};

_aoWin.LoginLog

=

"";

var

_sBaseHost

=

"",

_oLoginQrCodeImg

=

document.getElementById("loginQrCode");

if

(document.domain

==

"")

{

_sBaseHost

=

"";

}

else

if(location.hostname.match(/(wechat\.com)$/)){

_sBaseHost

=

"";

}else{

_sBaseHost

=

"";

}

var

show_tip

=

1,

_sCurUUId,

_oResetTimeout,

_aWebMMCallbacks

=

[],

_oDetactWebMMInterval

=

setInterval(function(){

if(_aoWin.WebMM){

clearInterval(_oDetactWebMMInterval);

var

callback;

while(callback

=

_aWebMMCallbacks.shift()){

if(typeof(callback)

!=

"function")

continue;

callback();

}

}

},

1000);

function

_logInPage(_asLog){

_aoWin.LoginLog

=

LoginLog

+

_asLog

+

"\n";

}

function

_afterLoadWebMMDo(callback){

if(!_aoWin.WebMM){

_aWebMMCallbacks.push(callback);

}else{

callback();

}

}

function

_reportNow(text){

_logInPage(text);

_afterLoadWebMMDo(function(){

WebMM.ossLog({Text:

text});

WebMM.flushOssLog();

});

}

var

reLoadQRImgCount

=

0,

loadQRCodeTime

=

0,

loadQRImgSucc

=

function(){

clearInterval(loadQRImgWatchDog);

_logInPage("Load

QRCode

Success,

time="

+

(new

Date().getTime()

-

loadQRCodeTime)

+

"ms,

reload

count:

"

+

reLoadQRImgCount);

},

loadQRImgFail

=

function(img){

_reportNow("Load

QRcode

fail!"

+

status

+

",

src:

"

+

img.src

+

",

time:

"

+

(new

Date().getTime()

-

loadQRCodeTime)

+

"ms");

},

loadQRImgWatchDog

=

null;

function

_loadQRImg(uuid)

{

_poll(uuid);

_logInPage("Load

QRCode

Start");

loadQRCodeTime

=

new

Date().getTime();

_oLoginQrCodeImg.onload

=

function(){

loadQRImgSucc();

_oLoginQrCodeImg.onload

=

null;

};

_oLoginQrCodeImg.onerror

=

function(){loadQRImgFail(this)};

_oLoginQrCodeImg.src

=

"https://login."+_sBaseHost+"/qrcode/"+uuid+"?t=webwx";

loadQRImgWatchDog

=

setInterval(function(){

if

(reLoadQRImgCount

>=

5)

{

_reset();

return;

}

reLoadQRImgCount++;

var

_img

=

new

Image();

_img.onload

=

function

()

{

if(!_oLoginQrCodeImg.onload)

return;

_oLoginQrCodeImg.onload

=

null;

_oLoginQrCodeImg.src

=

this.src;//replace

loadQRImgSucc();

};

_img.onerror

=

function(){loadQRImgFail(this)};

_img.src

=

_oLoginQrCodeImg.src

+

"&r="

+

new

Date().getTime();

},

5000);

}

var

_sSecondRequestTime

=

0,

_nAjaxTimeout

=

100

*

1000,

_nNewLoginFuncErrCount

=

0;

function

_poll(_asUUID)

{

var

_self

=

arguments.callee,

_nTime

=

0;

_sCurUUId

=

_asUUID;

_logInPage("_poll

Request

Start,

time:

"

+

new

Date().getTime());

_nTime

=

new

Date().getTime();

$.ajax({

type:

"GET",

url:

"https://login."

+

_sBaseHost

+

"/cgi-bin/mmwebwx-bin/login?uuid="

+

_asUUID

+

"&tip="

+

show_tip,

dataType:

"script",

cache:

false,

timeout:

_nAjaxTimeout,

success:

function(data,

textStatus,

jqXHR)

{

_logInPage("_poll

Request

Success,

code:

"

+

window.code

+

",

time:

"

+

(new

Date().getTime()

-

_nTime)

+

"ms");

switch

(_aoWin.code)

{

case

200:

_sSecondRequestTime

=

new

Date().getTime()

-

_sSecondRequestTime;

_logInPage("Second

Request

Success,

time:

"

+

_sSecondRequestTime

+

"ms");

clearTimeout(_oResetTimeout);

var

_fNewLoginFunc

=

function(){

$.ajax({

url:

_aoWin.redirect_uri

+

"&fun=new",//new

login

page

type:

"GET",

success:function(msg)

{

_logInPage("new

func

reponse,

reponseMsg:

"

+

msg);

var

code

=

msg.match(/<script>(.*)<\/script>/);

var

skey=msg.match(/<skey>(.*)<\/skey>/);

if(code){

eval(code[1]);

}else{

$("#container").show();

$("#login_container").hide();

}

if(skey

&&

skey[1]){

WebMM.model("account").setSkey(skey[1]);

}

},

error:function(jqXHR,

textStatus,

errorThrown){

_nNewLoginFuncErrCount++;

if(_nNewLoginFuncErrCount

>

5){

if(confirm("Call

new

login

page

func

error,

refresh?")){location.reload()}

return;

}

_reportNow(_aoWin.redirect_uri

+

"

New

login

page

func

error:

"

+

textStatus

+"

retryCount:"

+

_nNewLoginFuncErrCount);

setTimeout(_fNewLoginFunc,

500);

}

});

};

_fNewLoginFunc();

_reportNow("/cgi-bin/mmwebwx-bin/login,

Second

Request

Success,

uuid:

"

+

_asUUID

+

",

time:

"

+

_sSecondRequestTime

+

"ms");

break;

case

201:

clearTimeout(_oResetTimeout);

show_tip

=

0;

$('.errorMsg').hide();

$('.normlDesc').hide();

$('.successMsg').show();

_reportNow("/cgi-bin/mmwebwx-bin/login,

First

Request

Success,

uuid:

"

+

_asUUID);

_reportNow("/cgi-bin/mmwebwx-bin/login,

Second

Request

Start,

uuid:

"

+

_asUUID);

_sSecondRequestTime

=

new

Date().getTime();

//_nAjaxTimeout

=

5

*

1000;

_self(_asUUID);

break;

case

408:

setTimeout(function(){

_self(_asUUID);

},

500);

break;

case

400:

case

500:

_reset();

_afterLoadWebMMDo(function(){

_aoWin.Log.d("500,

Login

Poll

Svr

Exception");

});

break;

}

},

error:

function(jqXHR,

textStatus,

errorThrown)

{

if

(textStatus

==

'timeout')

{

setTimeout(function(){

_self(_asUUID);

},

500);

}

else

{

setTimeout(function(){

_self(_asUUID);

},

5000);

_logInPage("_poll

Request

Error:"

+

textStatus);

_afterLoadWebMMDo(function(){

_aoWin.Log.e("Login

Poll

Error:"

+

textStatus);

});

}

}

});

}

var

getUUIDCount

=

0,

_getUUIDWatchDog,

_bGetUUIDSuccess

=

false;//ajax

success?

function

_getUUID()

{

getUUIDCount++;

var

_self

=

arguments.callee,

_loadError

=

function(errorText){

_reportNow("Load

UUID

Error!

ErrorText:

"

+

errorText

+

"

getUUIDCount="

+

getUUIDCount);

if(getUUIDCount

>

5){

if

(confirm("Load

uuid

error.

Refresh?"))

{

location.reload();

}

}

setTimeout(function(){

_self();

},

500);

};

clearTimeout(_getUUIDWatchDog);

_getUUIDWatchDog

=

setTimeout(function(){

if(!_aoWin.QRLogin.code){

_logInPage("GetUUID

Timeout,

WatchDog

Run");

_self();

}

},

10000);

$.ajax({

type:

"GET",

url:

"https://login."

+

_sBaseHost

+

"/jslogin?appid=wx782c26e4c19acffb&redirect_uri="+encodeURIComponent(tocol+"http://"+location.host+"/cgi-bin/mmwebwx-bin/webwxnewloginpage")+"&fun=new&lang="

+

document.lang,

dataType:

"script",

cache:

false,

success

:

function(){

clearTimeout(_getUUIDWatchDog);

if(_bGetUUIDSuccess)

return;

if

(_aoWin.QRLogin

&&

_aoWin.QRLogin.code

==

200)

{

_logInPage("GetUUID

Success,

UUID="

+

QRLogin.uuid);

_bGetUUIDSuccess

=

true;

clearTimeout(_oResetTimeout);

_oResetTimeout

=

setTimeout(function(){

location.reload();//Note:

Don't

run

_reset().

If

you

run

_reset(),

there

will

may

have

many

_poll

request,

as

they

get

408

return

code

},

5

*

60

*1000);//5

mins

_loadQRImg(QRLogin.uuid);

}

else

{

var

QRLoginCode

=

(_aoWin.QRLogin

&&

_aoWin.QRLogin.code)

?

_aoWin.QRLogin.code

:

"None";

_logInPage("GetUUID

Error,

QRLogin.code="

+

QRLoginCode);

_loadError("QRLogin.code=

"

+

QRLoginCode);

}

},

error

:

function(xhr,

textStatus,

errorThrown){

_logInPage("GetUUID

Error,

textStatus="

+

textStatus);

_loadError(textStatus);

}

});

}

function

_reset(){

location.reload();

}

if

($("#login_container").is(":visible")

)

{

_getUUID();

}

var

_bHadLog

=

false;

function

_ossLog()

{

if

(_bHadLog)

return;

_bHadLog

=

true;

var

_sUvid

=

document.cookie.match(new

RegExp(

"(^|

)"+"webwxuvid"+"=([^;]*)(;|$)"));

if(!_sUvid

||

_sUvid.length

<

3)

return;

_sUvid

=

_sUvid[2];

(new

Image()).src

=

"/cgi-bin/mmwebwx-bin/webwxstatreport?funkey=indexdemo&uvid="+_sUvid+"&uuid="+_sCurUUId;

}

if($("img.guide").length

>

0)

{

var

_nTimer

=

0,

_oGuide$

=

$(".guide"),

_oGuideTrigger$

=

$("#guideTrigger,

#tipTrigger"),

_oMask$

=

$(".mask");

function

_back()

{

_nTimer

=

setTimeout(function()

{

_oMask$.stop().animate({opa

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論