The code is as follows:
foreach ($filenames as $k + $v) {if ($v! = "." && $v! = "...") {//need to fill in your Access key and Secret key $accessKey = '; $secretKey = "; $domain = "http://o8ouat0ny.qnssl.com/"; Building the Authentication object $auth = new \qiniu\auth ($accessKey, $secretKey); The space to upload $bucket = ' phone-recording '; Generate upload Token $token = $auth->uploadtoken ($bucket); The local path of the file to be uploaded $filePath = Public_path (). '/phone-records/'. $v; Uploaded to seven cattle after the saved file name $key = $v; Initializes the UploadManager object and uploads the file $uploadMgr = new UploadManager (); Download voucher validity time//$duetime = 31536000; Call UploadManager's Putfile method to upload a list of files ($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); } } }
return value:
http://o8ouat0ny.qnssl.com/xiaoyin04.mp3?token=0aWD7M62qvq1ehkx53Kx1yOR8qtawHOkg9lsp90W:wibT2Kc5KHlhc90KYDk4oXCXyPs=:eyJzY29wZSI6InBob25lLXJlY29yZGluZyIsImRlYWRsaW5lIjoxNDY1ODIxMTU5fQ==
Access occurs when:{"error":"bad oauth request"}
Reply content:
The code is as follows:
foreach ($filenames as $k + $v) {if ($v! = "." && $v! = "...") {//need to fill in your Access key and Secret key $accessKey = '; $secretKey = "; $domain = "http://o8ouat0ny.qnssl.com/"; Building the Authentication object $auth = new \qiniu\auth ($accessKey, $secretKey); The space to upload $bucket = ' phone-recording '; Generate upload Token $token = $auth->uploadtoken ($bucket); The local path of the file to be uploaded $filePath = Public_path (). '/phone-records/'. $v; Uploaded to seven cattle after the saved file name $key = $v; Initializes the UploadManager object and uploads the file $uploadMgr = new UploadManager (); Download voucher validity time//$duetime = 31536000; Call UploadManager's Putfile method to upload a list of files ($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); } } }
return value:
http://o8ouat0ny.qnssl.com/xiaoyin04.mp3?token=0aWD7M62qvq1ehkx53Kx1yOR8qtawHOkg9lsp90W:wibT2Kc5KHlhc90KYDk4oXCXyPs=:eyJzY29wZSI6InBob25lLXJlY29yZGluZyIsImRlYWRsaW5lIjoxNDY1ODIxMTU5fQ==
Access occurs when:{"error":"bad oauth request"}
Your download voucher 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