| 1 | 1 | ▶ | use Encode (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use Encode::Locale; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 0 | ▶ | sub Mojo::Weixin::_get_qrcode_image{ | ||||||||
|
Subroutine
_get_qrcode_image: not called CC=5 SCAR=34.0
| |||||||||||
| 4 | 0 | my $self = shift; | |||||||||
| 5 | 0 | my $qrcode_uuid = shift; | |||||||||
| 6 | 0 | my $api = 'https://login.weixin.qq.com/qrcode/'; | |||||||||
| 7 | #my @query_string = ( | ||||||||||
| 8 | # t => "webwx", | ||||||||||
| 9 | #); | ||||||||||
| 10 | 0 | my $url = $api . $qrcode_uuid; | |||||||||
| 11 | 0 | my $data = $self->http_get($url); | |||||||||
| 12 | 0 | ▶ | if( not defined $data){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 0 | $self->error("登录二维码下载失败"); | |||||||||
| 14 | 0 | return 0; | |||||||||
| 15 | } | ||||||||||
| 16 | 0 | $self->clean_qrcode(); | |||||||||
| 17 | 0 | ▶ | $self->die("未设置二维码保存路径") if not defined $self->qrcode_path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | eval{ | |||||||||
| 19 | 0 | ▶ | open(my $fh,">",$self->qrcode_path) or die "$!\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | binmode $fh; | |||||||||
| 21 | 0 | print $fh $data; | |||||||||
| 22 | 0 | close $fh; | |||||||||
| 23 | }; | ||||||||||
| 24 | 0 | ▶ | if($@){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | $self->error("二维码写入文件[ " . $self->qrcode_path . " ]失败: $@"); | |||||||||
| 26 | 0 | return 0; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 0 | my $filename_for_log = Encode::encode("utf8",Encode::decode(locale_fs,$self->qrcode_path)); | |||||||||
| 30 | #$self->info("二维码已下载到本地[ $filename_for_log ]\n二维码原始下载地址[ $url ]"); | ||||||||||
| 31 | 0 | $self->info("二维码已下载到本地[ $filename_for_log ]"); | |||||||||
| 32 | 0 | $self->emit(input_qrcode=>$self->qrcode_path,$data); | |||||||||
| 33 | 0 | return 1; | |||||||||
| 34 | } | ||||||||||
| 35 | 1 | 1; | |||||||||