Skip to content

抓取资源提示错误 #85

@GavinFoo

Description

@GavinFoo

http://developer.qiniu.com/docs/v6/api/reference/rs/fetch.html
这段代码为什么实现后总是提醒我 {"error":"bad token"} 呢

    $conf = Config::get('api.qiniuResource');

    $remote_url ='http://qiniu.u.qiniudn.com/'.$fileName;
    $enc_remote_url = Qiniu_Encode($remote_url);
    $encode_entry_uri = Qiniu_Encode_entry_uri($conf['BUCKET'],$fileName);
    $path = "/fetch/{$enc_remote_url}/to/{$encode_entry_uri}";
    $signing_str = $path + "\n";
    $encoded_sign = hash_hmac('sha1', $signing_str, $conf['API_SECRET'], true);
    $athorization = 'QBox '.$conf['API_KEY'] . ':' . Qiniu_Encode($encoded_sign);

    $headers = array(
      "Content-type: application/x-www-form-urlencoded",
      'Athorization: '.$athorization,
      'Host: iovip.qbox.me'
    );

    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,'http://iovip.qbox.me'.$path);
    curl_setopt ($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,'');
    $result = curl_exec($ch);
    $rinfo = curl_getinfo($ch);
    curl_close($ch);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions