Skip to content

Commit

Permalink
post_api接口返回json格式无效时给出原因提示
Browse files Browse the repository at this point in the history
  • Loading branch information
hexsum committed Apr 8, 2019
1 parent 0fcf066 commit ab6a609
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Weixin/Plugin/Openwx.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ sub call{
my($data,$ua,$tx) = @_;
if($tx->result->is_success){
$client->debug( $tx->res->body );
if($tx->res->headers->content_type =~m#text/json|application/json#){
if($tx->res->headers->content_type =~m#(text|application)/json#){
#文本类的返回结果必须是json字符串
my $json;
eval{$json = $client->decode_json($tx->res->body);$client->reform($json)};
if($@){$client->warn($@);return}
if($@){$client->warn("post_api返回的json内容无法正常解析: " . $@);return}
if(defined $json){
#暂时先不启用format的属性
#{code=>0,reply=>"回复的消息",format=>"text"}
Expand Down

0 comments on commit ab6a609

Please sign in to comment.