微信新永久素材

public function get_forever_media(){
        $access_token = $this->getAccessToken();
        $url = 'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token='.$access_token;
        $filepath = getcwd().'/data/members/virtual/20180711/50566e59d1145ceac73d47d19ec70a10.jpg';
        $path = new CURLFile(realpath($filepath));
        $type = 'image';
        //$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$access_token&type=$type";
        $ch1 = curl_init ();
        $data= array('media'=>$path);
        curl_setopt($ch1, CURLOPT_URL, $url);
        curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE);
        if (!empty($data)){
            curl_setopt($ch1, CURLOPT_POST, 1);
            curl_setopt($ch1, CURLOPT_POSTFIELDS, $data);
        }
        curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec ( $ch1 );
        curl_close ( $ch1 );
        return $result;
    }

猜你喜欢

转载自www.cnblogs.com/chentailin/p/9353678.html
今日推荐