点滴记忆

使用emlog搭建的站点

七牛异步第三方数据抓取sdk

2019-9-3 kurly

private function fetchpost($url, $body)
    {
        $headers = $this->auth->authorizationV2($url, "POST", $body, 'application/json');
        $headers['Content-Type']='application/json';
        $ret = Client::post($url, $body, $headers);
        if (!$ret->ok()) {
            return array(null, new Error($url, $ret));
        }
        $r = ($ret->body === null) ? array() : $ret->json();
        return array($r, null);
    }

    public function fetchas($url, $bucket, $callbackurl, $callbackbody, $callbackbodytype, $key){
        $req = array();
        $req['url'] = $url;
        $req['bucket'] = $bucket;
        if($callbackurl!=null){
            $req['callbackurl'] = $callbackurl;
        }
        if($callbackbody!=null){
            $req['callbackbody'] = $callbackbody;
        }
        if (!empty($key)) {
            $req['key'] = $key;
        }
        $req['file_type'] = 0;
        $url = 'http://api-z2.qiniu.com/sisyphus/fetch';
        $body = json_encode($req);
        return $this->fetchpost($url, $body);
    }

评论(0) 浏览(281)