Qiniu uploaded successfully, but when accessing, it always reported an error {'error':'bad oauth request'}

WBOY
Release: 2016-07-06 13:53:20
Original
2538 people have browsed it

The code is as follows:

<code>foreach ($filenames as $k => $v) {
            if ($v != "." && $v != "..") {
                // 需要填写你的 Access Key 和 Secret Key
                $accessKey = '';
                $secretKey = '';
                $domain = "http://o8ouat0ny.qnssl.com/";
                // 构建鉴权对象
                $auth = new \Qiniu\Auth($accessKey, $secretKey);
                // 要上传的空间
                $bucket = 'phone-recording';
                // 生成上传 Token
                $token = $auth->uploadToken($bucket);
                // 要上传文件的本地路径
                $filePath = public_path() . '/phone-records/' . $v;
                // 上传到七牛后保存的文件名
                $key = $v;
                // 初始化 UploadManager 对象并进行文件的上传
                $uploadMgr = new UploadManager();
                // 下载凭证有效时间
                //$duetime = 31536000;
                // 调用 UploadManager 的 putFile 方法进行文件的上传
                list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
                if (is_null($err)) {
                    //var_dump($domain.$ret['key'].'?e='.$duetime.'&token='.$token);
                    return $domain.$ret['key'].'?token='.$token;
                } else {
                    var_dump($err);
                }
            }
        }</code>
Copy after login
Copy after login

Return value:

<code>http://o8ouat0ny.qnssl.com/xiaoyin04.mp3?token=0aWD7M62qvq1ehkx53Kx1yOR8qtawHOkg9lsp90W:wibT2Kc5KHlhc90KYDk4oXCXyPs=:eyJzY29wZSI6InBob25lLXJlY29yZGluZyIsImRlYWRsaW5lIjoxNDY1ODIxMTU5fQ==</code>
Copy after login
Copy after login

Appears when accessing: {"error":"bad oauth request"}

Reply content:

The code is as follows:

<code>foreach ($filenames as $k => $v) {
            if ($v != "." && $v != "..") {
                // 需要填写你的 Access Key 和 Secret Key
                $accessKey = '';
                $secretKey = '';
                $domain = "http://o8ouat0ny.qnssl.com/";
                // 构建鉴权对象
                $auth = new \Qiniu\Auth($accessKey, $secretKey);
                // 要上传的空间
                $bucket = 'phone-recording';
                // 生成上传 Token
                $token = $auth->uploadToken($bucket);
                // 要上传文件的本地路径
                $filePath = public_path() . '/phone-records/' . $v;
                // 上传到七牛后保存的文件名
                $key = $v;
                // 初始化 UploadManager 对象并进行文件的上传
                $uploadMgr = new UploadManager();
                // 下载凭证有效时间
                //$duetime = 31536000;
                // 调用 UploadManager 的 putFile 方法进行文件的上传
                list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
                if (is_null($err)) {
                    //var_dump($domain.$ret['key'].'?e='.$duetime.'&token='.$token);
                    return $domain.$ret['key'].'?token='.$token;
                } else {
                    var_dump($err);
                }
            }
        }</code>
Copy after login
Copy after login

Return value:

<code>http://o8ouat0ny.qnssl.com/xiaoyin04.mp3?token=0aWD7M62qvq1ehkx53Kx1yOR8qtawHOkg9lsp90W:wibT2Kc5KHlhc90KYDk4oXCXyPs=:eyJzY29wZSI6InBob25lLXJlY29yZGluZyIsImRlYWRsaW5lIjoxNDY1ODIxMTU5fQ==</code>
Copy after login
Copy after login

Appears when accessing: {"error":"bad oauth request"}

Your download credentials are incorrect.
Documentation: http://developer.qiniu.com/article/developer/security/download-token.html

php demo: http://developer.qiniu.com/code/v7/sdk/php.html#download

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template