line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Weixin::Client; |
2
|
|
|
|
|
|
|
sub _sync { |
3
|
0
|
|
|
0
|
|
|
my $self = shift; |
4
|
0
|
0
|
|
|
|
|
return if $self->{_synccheck_running} ; |
5
|
0
|
|
|
|
|
|
$self->{_sync_running} = 1; |
6
|
0
|
|
|
|
|
|
my $api = 'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsync'; |
7
|
0
|
|
|
|
|
|
my @query_string = ( |
8
|
|
|
|
|
|
|
sid => $self->wxsid, |
9
|
|
|
|
|
|
|
skey => uri_escape($self->skey), |
10
|
|
|
|
|
|
|
r => $self->now(), |
11
|
|
|
|
|
|
|
skey => uri_escape($self->skey), |
12
|
|
|
|
|
|
|
pass_ticket => $self->pass_ticket, |
13
|
|
|
|
|
|
|
); |
14
|
0
|
|
|
|
|
|
my $post = { |
15
|
|
|
|
|
|
|
BaseRequest => {Uin => $self->wxuin,Sid=>$self->wxsid,}, |
16
|
|
|
|
|
|
|
SyncKey => $self->sync_key, |
17
|
|
|
|
|
|
|
rr => $self->now(), |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
my $callback = sub{ |
20
|
0
|
|
|
0
|
|
|
$self->{_sync_running} = 0; |
21
|
0
|
|
|
|
|
|
my $response = shift; |
22
|
0
|
0
|
|
|
|
|
print $response->content(),"\n" if $self->{debug}; |
23
|
0
|
|
|
|
|
|
my $d = $self->json_decode($response->content()); |
24
|
|
|
|
|
|
|
#return if $d->{BaseResponse}{Ret}!=0; |
25
|
0
|
|
|
|
|
|
$self->_parse_sync_data($d); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
}; |
28
|
0
|
|
|
|
|
|
my $url = gen_url($api,@query_string); |
29
|
|
|
|
|
|
|
$self->timer2( |
30
|
|
|
|
|
|
|
"_sync", |
31
|
|
|
|
|
|
|
$self->{_sync_interval}, |
32
|
|
|
|
|
|
|
sub{ |
33
|
0
|
0
|
|
0
|
|
|
print "POST $url\n" if $self->{debug}; |
34
|
0
|
|
|
|
|
|
$self->asyn_http_post( |
35
|
|
|
|
|
|
|
$url, |
36
|
|
|
|
|
|
|
("Content-Type"=>"application/json; charset=UTF-8"), |
37
|
|
|
|
|
|
|
Content=>$self->json_encode($post), |
38
|
|
|
|
|
|
|
$callback |
39
|
|
|
|
|
|
|
); |
40
|
0
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
1; |