File Coverage

blib/lib/Mojo/Weixin/Model/Remote/_webwxstatusnotify.pm
Criterion Covered Total %
statement 3 18 16.6
branch 0 4 0.0
condition 0 11 0.0
subroutine 1 3 33.3
pod n/a
total 4 36 11.1


line stmt bran cond sub pod time code
1 1     1   7 use strict;
  1         2  
  1         285  
2             sub Mojo::Weixin::_webwxstatusnotify {
3 0     0     my $self = shift;
4 0           my $id = shift;
5 0   0       my $code = shift || 3;
6 0           $self->debug("发送状态通知...");
7 0           my $api = "https://". $self->domain . "/cgi-bin/mmwebwx-bin/webwxstatusnotify";
8 0 0         my @query_string = (pass_ticket => $self->url_escape($self->pass_ticket)) if $self->pass_ticket;
9             my $post = {
10             BaseRequest => {
11             Uin => $self->wxuin,
12             Sid => $self->wxsid,
13             Skey => $self->skey,
14             DeviceID => $self->deviceid,
15             },
16 0   0 0     ClientMsgId => sub{my $r = sprintf "%.3f", rand();$r=~s/\.//g;return $self->now() . $r;}->(),
  0            
  0            
  0            
17             Code => $code,
18             FromUserName => $self->user->id,
19             ToUserName => $id || $self->user->id,
20             };
21              
22 0           my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://' . $self->domain . '/'},json=>$post);
23 0 0 0       if(not defined $json or (defined $json and $json->{BaseResponse}{Ret}!=0)){
      0        
24 0           $self->warn("发送状态通知失败");
25 0           return;
26             }
27 0           return 1;
28             }
29             1;