Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

抓取资源提示错误 #85

Closed
GavinFoo opened this issue Jul 13, 2014 · 4 comments
Closed

抓取资源提示错误 #85

GavinFoo opened this issue Jul 13, 2014 · 4 comments

Comments

@GavinFoo
Copy link

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);

@longbai
Copy link
Contributor

longbai commented Jul 14, 2014

accesskey 没有填吧

@longbai longbai closed this as completed Jul 14, 2014
@GavinFoo
Copy link
Author

我的A.K是 $conf['API_KEY'] 。

@longbai
Copy link
Contributor

longbai commented Jul 14, 2014

conf 里的 API key 里没有填吧

@longbai
Copy link
Contributor

longbai commented Jul 14, 2014

这类错误一般都是 key 没有填对

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants