调用二维码生成接口
发布于 5 年前 作者 itao 3114 次浏览 来自 问答

使用官方demo中的curl请求方式,出现以下情况

参数确保正确,在postman里测试正常,但是使用PHP,调用CURL方式,却一直出现这个错误

5 回复

可以给个scene带参数的例子吗 例如id=819

<html>

 <head>

  <title>PHP 测试</title>

 </head>

 <body>

 <?php

$url = “https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=rVZ7rrhwumNssz6b9kaTOrgF_tvZz9CXqZ-29MF94ppzvgixnjQs4Vr7ZTM_0nWbmZuc4g7ctYAmyCPxSJk2AX-kPhxHszTp0b3nUMX4K5DE4Er7-2eKTTXQDdU-gpAcPESbAFAETH”;

            $arr = array(‘path’=>‘pages/index/index’ , ‘scene’=>‘helloworld’);

            $content = json_encode($arr);

            $curl = curl_init($url);

            curl_setopt($curl, CURLOPT_HEADER, false);

            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

            curl_setopt($curl, CURLOPT_HTTPHEADER,

                    array(“Content-type: application/json”));

            curl_setopt($curl, CURLOPT_POST, true);

            curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

            $json_response = curl_exec($curl);

            $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

            curl_close($curl);

            echo ‘<p>’ + strlen($json_response) + ‘</p>’;

 ?>

 </body>

</html>

不能,参数用scene字段来传递

还有个问题就是page路径里不能带参数吗

参数以json字符串的形式 Post 过来,不要以表单提交

用的就是json格式

回到顶部