Beispiel #1
0
 public static function status($id)
 {
     $url = Config::API_HOST . "/status/get/prefop?id={$id}";
     $response = Client::get($url);
     if (!$response->ok()) {
         return array(null, new Error($url, $response));
     }
     return array($response->json(), null);
 }
Beispiel #2
0
 /**
  * 对资源文件进行处理
  *
  * @param $key   待处理的资源文件名
  * @param $fops   string|array  fop操作,多次fop操作以array的形式传入。
  *                eg. imageView2/1/w/200/h/200, imageMogr2/thumbnail/!75px
  *
  * @return array 文件处理后的结果及错误。
  *
  * @link http://developer.qiniu.com/docs/v6/api/reference/fop/
  */
 public function execute($key, $fops)
 {
     $url = $this->buildUrl($key, $fops);
     $resp = Client::get($url);
     if (!$resp->ok()) {
         return array(null, new Error($url, $resp));
     }
     if ($resp->json() !== null) {
         return array($resp->json(), null);
     }
     return array($resp->body, null);
 }
Beispiel #3
0
 public static function put($upToken, $key, $data, $config, $params, $mime, $checkCrc)
 {
     $fields = array('token' => $upToken);
     if ($key === null) {
         $fname = 'filename';
     } else {
         $fname = $key;
         $fields['key'] = $key;
     }
     if ($checkCrc) {
         $fields['crc32'] = Functions::crc32_data($data);
     }
     if ($params) {
         foreach ($params as $k => $v) {
             $fields[$k] = $v;
         }
     }
     $response = Client::multipartPost($config->getUpHost(), $fields, 'file', $fname, $data, $mime);
     if (!$response->ok()) {
         return array(null, new Error($config->getUpHost(), $response));
     }
     return array($response->json(), null);
 }
Beispiel #4
0
 private function post($url, $body)
 {
     $headers = $this->auth->authorization($url, $body, 'application/x-www-form-urlencoded');
     $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);
 }
Beispiel #5
0
 private function post($url, $data)
 {
     $this->currentUrl = $url;
     $headers = array('Authorization' => 'UpToken ' . $this->upToken);
     return Client::post($url, $data, $headers);
 }