Mini Program generates QR code interface B and asks for advice on what went wrong.

The problem with

is that the return has neither error nor data, and the document says it will return binary and convert it to a picture. But now there is nothing. I don"t know what went wrong. Ask for help

contorller

function getIssueQrcodeAction()
            {
                // $issueId     =    $this->request->getPost("issueId");
                $issueId = 2;
                $page     =    "pages/listPage/article/article?issueId=";
                $test = new GetQrcode();
                $t = $test->get_qrcode($page,$issueId);

                print_r($t);
                

            }
service
Class GetQrcode
    {
public function get_qrcode($page,$issueId) {
        header("content-type:image/png");
        $uid = 6;
        $data = array();
        $data["scene"] = $issueId;
        $data["page"] = $page;
        $date["width"] = 450;
        $data = json_encode($data);
        // $access = json_decode($this->get_access_token(),true);
           $a = new WeixinUsers();
        $access_token = $a->access_token();
        $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$access_token;
        $da = $this->get_http_array($url,$data);

       return json_encode(array("pictures"=>$da));
        // $this->assign("data",$da);
        // $this->fetch();

    }
    public function get_http_array($url,$post_data) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   //print_r();1
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        $output = curl_exec($ch);
        curl_close($ch);
        $out = json_decode($output);
        return $out;
    }
 }

https://mp.weixin.qq.com/debu.

Feb.27,2021

httphttps?httpsget_http_array()

clipboard.png

The problem with

is that it returns neither error nor data, and the document says it will return binary and convert it to an image. But now there is nothing. I don't know what went wrong. Ask for help


  $data = [
    'scene'=>$issueId,
    'page'=>$page,
    'width'=>450,
    'auto_color'=>false,
    'line_color'=>["r"=>0,"g"=>0,"b"=>0],
];

try adding all the parameters. There should be a return

.

$out = json_decode (the binary stream returned by $output); $output is already a binary stream. Do not use json_decode, to receive it directly using file_put_contents.


I am not sure whether it is because the second API needs to be online with Mini Program first. At present, my situation is the same as yours. I want to try again after I go online, but I failed the examination.


there are several questions. The first is a POST request, which means you use POST to get a picture.
second, please do not specify your page,. If Mini Program is not online, specify that page is the third
that cannot be displayed. In http_request, curl_setopt ($curl,CURLOPT_POSTFIELDS,http_build_query ($data));)
fourth, please set the sending header to application/json, or you will regret it.
the last question, please do not directly on the code, look at the code is very annoying, a waste of time, unless very idle people, of course, I also calculate


page page do not take parameters, parameters in scene


http response read the response stream, and then convert to png or the format you want

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bee554-31433.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bee554-31433.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?