Qiniu has successfully uploaded the file, but the error {"error": "badoauthrequest"} is always reported during access "}

Source: Internet
Author: User
Tags oauth
The code is as follows: {code ...} returned value: {code ...} the following code appears during access: {& quot; error & quot;: & quot; badoauthrequest & quot:

Foreach ($ filenames as $ k => $ v) {if ($ v! = "." & $ V! = "...") {// Enter your Access Key and Secret Key $ accessKey = ''; $ secretKey =''; $ domain =" http://o8ouat0ny.qnssl.com/ "; // Construct the authentication object $ auth = new \ Qiniu \ Auth ($ accessKey, $ secretKey); // the space to be uploaded $ bucket = 'phone-recording '; // Generate the upload Token $ token = $ auth-> uploadToken ($ bucket); // The local path of the file to be uploaded $ filePath = public_path (). '/phone-records /'. $ v; // name of the file saved after the upload to Qiniu $ key = $ v; // initialize the UploadManager object and upload the file $ uploadMgr = new UploadManager (); // download credential validity period // $ duetime = 31536000; // call the putFile method of UploadManager to upload the file list ($ ret, $ er R) = $ 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 );}}}

Return value:

http://o8ouat0ny.qnssl.com/xiaoyin04.mp3?token=0aWD7M62qvq1ehkx53Kx1yOR8qtawHOkg9lsp90W:wibT2Kc5KHlhc90KYDk4oXCXyPs=:eyJzY29wZSI6InBob25lLXJlY29yZGluZyIsImRlYWRsaW5lIjoxNDY1ODIxMTU5fQ==

The following error occurs during access:{"error":"bad oauth request"}

Reply content:

The code is as follows:

Foreach ($ filenames as $ k => $ v) {if ($ v! = "." & $ V! = "...") {// Enter your Access Key and Secret Key $ accessKey = ''; $ secretKey =''; $ domain =" http://o8ouat0ny.qnssl.com/ "; // Construct the authentication object $ auth = new \ Qiniu \ Auth ($ accessKey, $ secretKey); // the space to be uploaded $ bucket = 'phone-recording '; // Generate the upload Token $ token = $ auth-> uploadToken ($ bucket); // The local path of the file to be uploaded $ filePath = public_path (). '/phone-records /'. $ v; // name of the file saved after the upload to Qiniu $ key = $ v; // initialize the UploadManager object and upload the file $ uploadMgr = new UploadManager (); // download credential validity period // $ duetime = 31536000; // call the putFile method of UploadManager to upload the file list ($ ret, $ er R) = $ 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 );}}}

Return value:

http://o8ouat0ny.qnssl.com/xiaoyin04.mp3?token=0aWD7M62qvq1ehkx53Kx1yOR8qtawHOkg9lsp90W:wibT2Kc5KHlhc90KYDk4oXCXyPs=:eyJzY29wZSI6InBob25lLXJlY29yZGluZyIsImRlYWRsaW5lIjoxNDY1ODIxMTU5fQ==

The following error occurs during access:{"error":"bad oauth request"}

Your download credential is incorrect.
Document: http://developer.qiniu.com/article/developer/security/download-token.html

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.