微信公众平台开发(150)——从新浪云SAE上传图片到图文消息

从新浪云SAE上传图片到图文消息,只能用于图文消息中,

没有个数限制

        if (!empty($_FILES['qrcode']['name'])){
            $filename = time().".jpg";
            file_put_contents(SAE_TMP_PATH."/".$filename, file_get_contents($_FILES['qrcode']['tmp_name']));
            Vendor('Weixin.wxyhq_class');
            $weixin = new \weixin();
            $data2 = array("media" => "@".SAE_TMP_PATH.$filename); ////////
           
            $result2 = $weixin->upload_image_media_raw($data2);
            if (isset($result2['url'])){
                $data['picture'] = $result2['url'];
                $member->add($data);
                $this->success('添加成功!','member');
            }else{
                $this->error('qrcode 失败');
            }
        }else{
            $this->error('qrcode 没有');
        }
        
       
        $data = array("media" => "@".SAE_TMP_PATH.$filename);
        $result2 = $weixin->upload_image_media_raw($data);
        var_dump($result2);

 

posted @ 2019-07-11 23:04 方倍工作室 阅读(...) 评论(...) 编辑 收藏