line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Weixin::Client; |
2
|
1
|
|
|
1
|
|
407
|
use Weixin::Client::Private::_get_qrcode_uuid; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
278
|
use Weixin::Client::Private::_get_qrcode_image; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
399
|
use Weixin::Client::Private::_is_need_login; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
367
|
|
5
|
|
|
|
|
|
|
sub _login{ |
6
|
0
|
|
|
0
|
|
|
my $self = shift; |
7
|
0
|
|
|
|
|
|
console "客户端准备登录...\n"; |
8
|
0
|
0
|
|
|
|
|
unless($self->_is_need_login()){ |
9
|
0
|
|
|
|
|
|
console "微信登录成功\n"; |
10
|
0
|
|
|
|
|
|
return 1; |
11
|
|
|
|
|
|
|
} |
12
|
0
|
|
|
|
|
|
my $show_tip = 1; |
13
|
0
|
|
|
|
|
|
my $api = 'https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login'; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $qrcode_uuid = $self->_get_qrcode_uuid() ; |
16
|
0
|
0
|
|
|
|
|
unless(defined $qrcode_uuid){ |
17
|
0
|
|
|
|
|
|
console "无法获取到登录二维码,登录失败\n"; |
18
|
0
|
|
|
|
|
|
exit -1 ; |
19
|
|
|
|
|
|
|
} |
20
|
0
|
|
|
|
|
|
$self->_get_qrcode_image($qrcode_uuid); |
21
|
0
|
|
|
|
|
|
my $i=1; |
22
|
0
|
|
|
|
|
|
console "等待手机微信扫描二维码...\n"; |
23
|
0
|
|
|
|
|
|
while(1){ |
24
|
0
|
|
|
|
|
|
my @query_string = ( |
25
|
|
|
|
|
|
|
uuid => $qrcode_uuid, |
26
|
|
|
|
|
|
|
tip => $show_tip , |
27
|
|
|
|
|
|
|
_ => $self->now(), |
28
|
|
|
|
|
|
|
); |
29
|
0
|
|
|
|
|
|
my $r = $self->http_get(Weixin::Util::gen_url($api,@query_string)); |
30
|
0
|
0
|
|
|
|
|
next unless defined $r; |
31
|
0
|
|
|
|
|
|
my %data = $r=~/window\.(.+?)=(.+?);/g; |
32
|
0
|
0
|
|
|
|
|
$data{redirect_uri}=~s/^["']|["']$//g if defined $data{redirect_uri}; |
33
|
0
|
0
|
|
|
|
|
if($data{code} == 408){ |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
select undef,undef,undef,0.5; |
35
|
0
|
0
|
|
|
|
|
if($i==5){ |
36
|
0
|
|
|
|
|
|
console "登录二维码已失效,重新获取二维码\n"; |
37
|
0
|
|
|
|
|
|
$qrcode_uuid = $self->_get_qrcode_uuid(); |
38
|
0
|
|
|
|
|
|
$self->_get_qrcode_image($qrcode_uuid); |
39
|
0
|
|
|
|
|
|
$i = 1; |
40
|
0
|
|
|
|
|
|
next; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
$i++; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif($data{code} == 201){ |
45
|
0
|
|
|
|
|
|
console "手机微信扫码成功,请在手机微信上点击 [登录] 按钮...\n"; |
46
|
0
|
|
|
|
|
|
$show_tip = 0; |
47
|
0
|
|
|
|
|
|
next; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
elsif($data{code} == 200){ |
51
|
0
|
|
|
|
|
|
console "正在进行登录...\n"; |
52
|
0
|
|
|
|
|
|
my $data = $self->http_get($data{redirect_uri} . "&fun=new"); |
53
|
|
|
|
|
|
|
#0OK@crypt_859d8a8a_3f3db5290570080d1db29da9507e35dersuMHe7xmA0aHW1D138122335hWdpMVCMqXIVfhXLcsJxYrC6bv785tVDLZAres096ZE%3D
|
54
|
0
|
|
|
|
|
|
my %d = $data=~/<([^<>]+?)>([^<>]+?)<\/\1>/g; |
55
|
0
|
0
|
|
|
|
|
return 0 if $d{ret} != 0; |
56
|
0
|
|
|
|
|
|
$self->skey($d{skey}); |
57
|
0
|
|
|
|
|
|
$self->wxsid($d{wxsid}); |
58
|
0
|
|
|
|
|
|
$self->wxuin($d{wxuin}); |
59
|
0
|
|
|
|
|
|
$self->pass_ticket($d{pass_ticket}); |
60
|
0
|
|
|
|
|
|
console "微信登录成功\n"; |
61
|
0
|
|
|
|
|
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
elsif($data{code} == 400){ |
64
|
0
|
|
|
|
|
|
console "登录错误,客户端退出\n"; |
65
|
0
|
|
|
|
|
|
exit; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
elsif($data{code} == 500){ |
68
|
0
|
|
|
|
|
|
console "登录错误,客户端尝试重新登录...\n"; |
69
|
0
|
|
|
|
|
|
$i = 1; |
70
|
0
|
|
|
|
|
|
$show_tip = 1; |
71
|
0
|
|
|
|
|
|
$qrcode_uuid = $self->_get_qrcode_uuid(); |
72
|
0
|
|
|
|
|
|
$self->_get_qrcode_image($qrcode_uuid); |
73
|
0
|
|
|
|
|
|
next; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |