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