| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Weixin::Client; |
|
2
|
|
|
|
|
|
|
sub _init { |
|
3
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
4
|
0
|
|
|
|
|
|
my $api = "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit"; |
|
5
|
0
|
|
|
|
|
|
my @query_string = ( |
|
6
|
|
|
|
|
|
|
pass_ticket => $self->pass_ticket, |
|
7
|
|
|
|
|
|
|
r => $self->now(), |
|
8
|
|
|
|
|
|
|
skey => uri_escape($self->skey), |
|
9
|
|
|
|
|
|
|
pass_ticket => $self->pass_ticket, |
|
10
|
|
|
|
|
|
|
); |
|
11
|
0
|
|
|
|
|
|
my $post = { |
|
12
|
|
|
|
|
|
|
BaseRequest => { |
|
13
|
|
|
|
|
|
|
Uin => $self->wxuin, |
|
14
|
|
|
|
|
|
|
Sid => $self->wxsid, |
|
15
|
|
|
|
|
|
|
Skey => $self->skey, |
|
16
|
|
|
|
|
|
|
DeviceID => $self->deviceid, |
|
17
|
|
|
|
|
|
|
}, |
|
18
|
|
|
|
|
|
|
}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my @headers = ( |
|
21
|
|
|
|
|
|
|
Referer => "https://wx.qq.com/?&lang=zh_CN", |
|
22
|
|
|
|
|
|
|
); |
|
23
|
0
|
|
|
|
|
|
my $json = $self->http_post(Weixin::Util::gen_url($api,@query_string),@headers,("Content-Type"=>"application/json; charset=UTF-8"),Content=>$self->json_encode($post)); |
|
24
|
0
|
|
|
|
|
|
my $d = $self->json_decode($json); |
|
25
|
0
|
0
|
|
|
|
|
return if $d->{BaseResponse}{Ret}!=0; |
|
26
|
0
|
|
|
|
|
|
my @user_key = qw(Uin Id NickName HeadImgUrl Sex Signature PYInitial PYQuanPin RemarkName RemarkPYInitial RemarkPYQuanPin ); |
|
27
|
0
|
|
|
|
|
|
my @chartroom_key = qw(ChatRoomUin MemberCount OwnerUin ChatRoomId ChatRoomName); |
|
28
|
0
|
|
|
|
|
|
my @member_key = qw(Uin Id NickName); |
|
29
|
0
|
|
|
|
|
|
my @friend_key = qw(HeadImgUrl NickName PYInitial PYQuanPin Alias Province City Sex Id Uin Signature DisplayName RemarkName RemarkPYInitial RemarkPYQuanPin); |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$d->{User}{Id} = $d->{User}{UserName} ;delete $d->{User}{UserName}; |
|
|
0
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$d->{User}{Sex} = Weixin::Util::code2sex($d->{User}{Sex}); |
|
33
|
0
|
0
|
|
|
|
|
$self->sync_key($d->{SyncKey}) if $d->{SyncKey}{Count}!=0; |
|
34
|
0
|
0
|
|
|
|
|
$self->skey($d->{SKey}) if $d->{SKey}; |
|
35
|
0
|
|
|
|
|
|
@{$self->{_data}{user}}{@user_key} = map {$_=encode_utf8($_);$_;} @{$d->{User}}{@user_key}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if($d->{Count}!=0){ |
|
38
|
0
|
|
|
|
|
|
for my $each(@{$d->{ContactList}}) { |
|
|
0
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if($self->is_chatroom($each->{UserName})){#chatroom |
|
40
|
0
|
|
|
|
|
|
$each->{ChatRoomUin} = $each->{Uin};delete $each->{Uin}; |
|
|
0
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$each->{ChatRoomId} = $each->{UserName};delete $each->{UserName}; |
|
|
0
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$each->{ChatRoomName} = $each->{NickName};delete $each->{NickName}; |
|
|
0
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $chatroom = {}; |
|
44
|
0
|
|
|
|
|
|
@{$chatroom}{@chartroom_key} = map {$_=encode_utf8($_);$_;} @{$each}{@chartroom_key}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$chatroom->{Member} = []; |
|
46
|
0
|
|
|
|
|
|
for my $m (@{$each->{MemberList}}){ |
|
|
0
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$m->{Id} = $m->{UserName};delete $m->{UserName}; |
|
|
0
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $member = {}; |
|
49
|
0
|
|
|
|
|
|
@{$member}{@member_key} = map {$_=encode_utf8($_);$_;} @{$m}{@member_key}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
@{$member}{@chartroom_key} = @{$chatroom}{@chartroom_key}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
push @{$chatroom->{Member}},$member; |
|
|
0
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
|
53
|
0
|
|
|
|
|
|
$self->add_chatroom($chatroom,1); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
else{#friend |
|
56
|
0
|
|
|
|
|
|
$each->{Id} = $each->{UserName};delete $each->{UserName}; |
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$each->{Sex} = Weixin::Util::code2sex($each->{Sex}); |
|
58
|
0
|
|
|
|
|
|
my $friend = {}; |
|
59
|
0
|
|
|
|
|
|
@{$friend}{@friend_key} = map {$_=encode_utf8($_);$_;} @{$each}{@friend_key}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$self->add_friend($friend); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
1; |