line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Weixin::Client; |
2
|
|
|
|
|
|
|
sub _update_chatroom_member{ |
3
|
0
|
|
|
0
|
|
|
my $self = shift; |
4
|
0
|
|
|
|
|
|
my $chatroom = shift; |
5
|
0
|
|
|
|
|
|
my @list; |
6
|
0
|
|
|
|
|
|
for(@{$chatroom->{Member}}){ |
|
0
|
|
|
|
|
|
|
7
|
0
|
0
|
|
|
|
|
push @list,{UserName=>$_->{Id},ChatRoomId=>defined($chatroom->{ChatRoomUin})?$chatroom->{ChatRoomUin}+0:""} if defined $_->{Id}; |
|
|
0
|
|
|
|
|
|
8
|
|
|
|
|
|
|
} |
9
|
0
|
|
|
|
|
|
my $post = { |
10
|
|
|
|
|
|
|
BaseRequest => { |
11
|
|
|
|
|
|
|
Uin => $self->wxuin, |
12
|
|
|
|
|
|
|
DeviceID => $self->deviceid, |
13
|
|
|
|
|
|
|
Sid => $self->wxsid, |
14
|
|
|
|
|
|
|
Skey => $self->skey, |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
Count => $chatroom->{MemberCount}, |
17
|
|
|
|
|
|
|
List => \@list, |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $api = "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact"; |
21
|
0
|
|
|
|
|
|
my @query_string = ( |
22
|
|
|
|
|
|
|
type => "ex", |
23
|
|
|
|
|
|
|
pass_ticket => $self->pass_ticket, |
24
|
|
|
|
|
|
|
r => $self->now(), |
25
|
|
|
|
|
|
|
skey => uri_escape($self->skey), |
26
|
|
|
|
|
|
|
pass_ticket => $self->pass_ticket, |
27
|
|
|
|
|
|
|
); |
28
|
0
|
|
|
|
|
|
my $json = $self->http_post(gen_url($api,@query_string),("Content-Type"=>"application/json; charset=UTF-8"),Content=>$self->json_encode($post)); |
29
|
0
|
0
|
|
|
|
|
return unless defined $json; |
30
|
0
|
|
|
|
|
|
my $d = $self->json_decode($json); |
31
|
0
|
0
|
|
|
|
|
return unless defined $d; |
32
|
0
|
0
|
|
|
|
|
return if $d->{BaseResponse}{Ret}!=0; |
33
|
0
|
0
|
|
|
|
|
return if $d->{Count}==0; |
34
|
0
|
|
|
|
|
|
my %member_info; |
35
|
0
|
|
|
|
|
|
my @member_key = qw(HeadImgUrl NickName PYInitial PYQuanPin Alias Province City Sex Id Uin Signature DisplayName RemarkName RemarkPYInitial RemarkPYQuanPin); |
36
|
0
|
|
|
|
|
|
my @chartroom_key = qw(ChatRoomUin MemberCount OwnerUin ChatRoomId ChatRoomName); |
37
|
0
|
|
|
|
|
|
for my $e (@{$d->{ContactList}}){ |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$e->{ChatRoomUin} = $e->{ChatRoomId};delete $e->{ChatRoomId}; |
|
0
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
next if $e->{ChatRoomUin} ne $chatroom->{ChatRoomUin}; |
40
|
0
|
|
|
|
|
|
$e->{Sex} = code2sex($e->{Sex}); |
41
|
0
|
|
|
|
|
|
$e->{Id} = $e->{UserName};delete $e->{UserName}; |
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
@{$member_info{$e->{Id}}}{@member_key} = map {$_=encode_utf8($_);$_} (@{$e}{@member_key}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
@{$member_info{$e->{Id}}}{@chartroom_key} = @{$chatroom}{@chartroom_key}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
for (@{$chatroom->{Member}}) { |
|
0
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if(exists $member_info{$_->{Id}}){ |
48
|
0
|
|
|
|
|
|
$_ = $member_info{$_->{Id}}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
1; |