get() public static méthode

public static get ( $url, array $headers = [] )
$headers array
Exemple #1
0
 public function testFop()
 {
     global $testAuth;
     $base_url = 'http://private-res.qiniudn.com/gogopher.jpg?exif';
     $private_url = $testAuth->privateDownloadUrl($base_url);
     $response = Client::get($private_url);
     $this->assertEquals(200, $response->statusCode);
 }
Exemple #2
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);
 }
Exemple #3
0
 public function testGetQiniu()
 {
     $response = Client::get('up.qiniu.com');
     $this->assertEquals(405, $response->statusCode);
     $this->assertNotNull($response->body);
     $this->assertNotNull($response->xReqId());
     $this->assertNotNull($response->xLog());
     $this->assertNotNull($response->error);
 }
Exemple #4
0
 /**
  * 上传文件格式
  *
  * @param $url
  * @param string $path
  * @return array
  */
 public function action($url, $path = '/tmp')
 {
     $this->url = $this->auth->privateDownloadUrl($url);
     $response = Client::get($this->url);
     if ($response->statusCode === 200) {
         $path .= DIRECTORY_SEPARATOR . $this->fileName;
         file_put_contents($path, $response->body);
         return ['path' => $path, 'name' => $this->fileName, 'status' => 0];
     }
     return ['path' => '', 'name' => '', 'status' => $response->statusCode];
 }
Exemple #5
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);
 }
Exemple #6
0
 public function returnImage()
 {
     if ($this->insert) {
         $this->imgurl = $this->baseimg . '?watermark/3' . $this->insert;
     }
     $image = QiniuClient::get($this->imgurl);
     $image = $image->body;
     if (function_exists('app') && is_a($app = app(), 'Illuminate\\Foundation\\Application')) {
         $response = \Response::make($image);
         $response->header('Content-Type', 'image/jpg');
         return $response;
     }
     header('Content-Type:image/jpg');
     $response = $image;
     return $response;
 }
Exemple #7
0
 public function __call($method, $args)
 {
     $key = $args[0];
     $cmd = $method;
     $mode = null;
     if (count($args) > 1) {
         $mode = $args[1];
     }
     if (count($args) > 2) {
         $options = $args[2];
     }
     $options = array();
     $url = $this->buildUrl($key, $cmd, $mode, $options);
     $r = Client::get($url);
     if (!$r->ok()) {
         return array(null, new Error($url, $r));
     }
     if ($r->json() != null) {
         return array($r->json(), null);
     }
     return array($r->body, null);
 }
Exemple #8
0
}
if ($_FILES['userfile']['type'] != 'image/jpeg') {
    echo '本示例只支持JPEG格式的图片文件。请返回并选择一个本地的JPEG文件。';
    exit;
}
$auth = new Auth($_POST['ak'], $_POST['sk']);
$token = $auth->uploadToken($_POST['bucket'], null, 3600, null);
$uploadManager = new UploadManager();
list($ret, $err) = $uploadManager->putFile($token, null, $_FILES['userfile']['tmp_name']);
if ($err != null) {
    echo "上传失败。错误消息:" . $err->message();
    exit;
}
echo '<h1>图片鉴别</h1>';
$imgSrc = $_POST['domain'] . '/' . $ret['key'];
$ret = Client::get($imgSrc . '?nrop');
if (!$ret->ok()) {
    echo '鉴别失败。额外信息:' . $ret . '<br>';
    exit;
}
$json = $ret->json();
$boolarray = array(false => 'false', true => 'true');
echo '<table border=\\"2\\"><tr><th>字段</th><th>值</th><th>含义</th></tr>';
echo '<tr><td>图片</td><td>' . $json['fileList'][0]['name'] . '</td><td><img src="' . $imgSrc . '" alt="上传图片" width=400px/></td></tr>';
echo '<tr><td>message</td><td>' . $json['message'] . '</td><td>对应code的描述信息。</td></tr>';
echo '<tr><td>code</td><td>' . $json['code'] . '</td><td>处理状态:<br>0:调用成功; <br>1:授权失败; <br>2:模型ID错误; <br>3:没有上传文件; <br>4:API版本号错误; <br>5:API版本已弃用; <br>6:secretId 错误; <br>7:任务Id错误,您的secretId不能调用该任务; <br>8:secretId状态异常; <br>9:尚未上传证书; <br>100:服务器错误; <br>101:未知错误</td></tr>';
echo '<tr><td>timestamp</td><td>' . $json['timestamp'] . '</td><td>时间戳。' . gmdate("Y-m-d H:i:s", $json['timestamp']) . '</td></tr>';
echo '<tr><td>label</td><td>' . $json['fileList'][0]['label'] . '</td><td>介于0-2间的整数,表示该图像被机器判定为哪个分类,分别对应: <br>0:色情; <br>1:性感; <br>2:正常;</td></tr>';
echo '<tr><td>rate</td><td>' . $json['fileList'][0]['rate'] . '</td><td>介于0-1间的浮点数,表示该图像被识别为某个分类的概率值,概率越高、机器越肯定;您可以根据您的需求确定需要人工复审的界限。</td></tr>';
echo '<tr><td>review</td><td>' . $boolarray[$json['fileList'][0]['review']] . '</td><td>是否需要人工复审该图片,鉴黄服务是否对结果确定(true:不确定,false:确定)</td></tr>';
echo '</table>';
Exemple #9
0
 private function get($url)
 {
     $headers = $this->auth->authorization($url);
     $ret = Client::get($url, $headers);
     if (!$ret->ok()) {
         return array(null, new Error($url, $ret));
     }
     return array($ret->json(), null);
 }
Exemple #10
0
        $props['stat:putTime'] = gmdate("Y-m-d H:i:s", $ret['putTime'] / 10000000);
    }
    // NROP
    $ret = Client::get("http://{$domain}/{$sn}?nrop");
    if ($ret->ok()) {
        $json = $ret->json();
        $boolarray = array(false => 'false', true => 'true');
        $props['nrop:code(0:调用成功)'] = $json['code'];
        $props['nrop:label(0:色情;1:性感;2:正常)'] = $json['fileList'][0]['label'];
        $props['nrop:rate(概率)'] = $json['fileList'][0]['rate'];
        $props['nrop:review(人工复审?)'] = $boolarray[$json['fileList'][0]['review']];
    } else {
        $props['nropfailure'] = $ret->body;
    }
    // EXIF
    $ret = Client::get("http://{$domain}/{$sn}?exif");
    $props['exif'] = $ret->body;
    $smarty->assign('props', $props);
}
if ($mode != null) {
    $smarty->assign('mode', $mode);
    if ($width != null) {
        $smarty->assign('width', $width);
    }
    if ($height != null) {
        $smarty->assign('height', $height);
    }
}
$smarty->display('index.tpl');
function console_log($data)
{