首页 技术 正文
技术 2022年11月15日
0 收藏 325 点赞 4,293 浏览 1019 个字

1.踩坑需求:获取小程序的二维码

2.踩坑接口:

https://api.weixin.qq.com/wxa/getwxacode?access_token=ACCESS_TOKEN3

踩坑代码

 public function GetCode2(Request $request)
{
$path = $request['path'];
$app = WXUtil::funcGetWXAPP('app.jmeii');
$response = $app->app_code->getQrCode($path);
$response = $this->BinToStr($response);
$this->prop_data_api['appcode'] = $response;
return $this->funcReturnApi();
} public function GetCode()
{
$client = new Client();
$entity_site = \App\t\t_c_site_a_wx::find('app.jmeii');
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $entity_site->sitewx_access_token;
// $postdata = $postdata = json_encode($postdata);
$temp = $client->request('POST', $url, [
'json' => [
'scene' => 'qdsad12321312312',
'page' => 'pages/__index__/__index__',
'auto_color' => FALSE
]
]);
$response = $temp->getBody();
return $response;
}

问题描述:

请求代码与步骤不存在问题,但返回数据为空,连错误码都没有。所以尝试使用了两种方式请求

问题原因:

在用curl,或者其他语言的其他请求函数请求到正常的数据后,千万不要用json_encode()处理返回来的数据。因为返回的是二进制的图片文件,经过json处理后就空了。

解决过程:

参考博客发现有人踩过,参阅遂解决。博客链接 https://blog.csdn.net/jesterxu/article/details/78225796

总结:

遇到问题无法解决,先查找是否有人存在同样问题,可先进行参考

上一篇: SAS学习笔记1
下一篇: Django开发之module
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918