Home  >  Article  >  Backend Development  >  七牛SDK PHP挣扎两个小时 麻烦给个靠谱点的demo吧

七牛SDK PHP挣扎两个小时 麻烦给个靠谱点的demo吧

WBOY
WBOYOriginal
2016-06-06 20:46:501074browse

按照官方API提示这样写 就是给抛个错误 { error: 'bad auth'}或者error: "no such bucket" demo都是民间的 各种错误

<code><?php require_once("qiniu/rs.php");

$bucket = 'xxxxxx这个隐藏了';
$accessKey = 'xxxxxx';
$secretKey = 'xxxxxx';

Qiniu_SetKeys($accessKey, $secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
$upToken = $putPolicy->Token(null);

?>

    
      <form method="post" action="http://up.qiniu.com/" enctype="multipart/form-data">
        <input name="key" type="hidden" value="<resource key>">
        <input name="x:<custom_field_name>" type="hidden" value="<custom value>">
        <input name="token" type="hidden" value="<token>">
        <input name="file" type="file">
        ...
      </form>
    

</code>

这个问题已被关闭,原因:

回复内容:

按照官方API提示这样写 就是给抛个错误 { error: 'bad auth'}或者error: "no such bucket" demo都是民间的 各种错误

<code><?php require_once("qiniu/rs.php");

$bucket = 'xxxxxx这个隐藏了';
$accessKey = 'xxxxxx';
$secretKey = 'xxxxxx';

Qiniu_SetKeys($accessKey, $secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
$upToken = $putPolicy->Token(null);

?>

    
      <form method="post" action="http://up.qiniu.com/" enctype="multipart/form-data">
        <input name="key" type="hidden" value="<resource key>">
        <input name="x:<custom_field_name>" type="hidden" value="<custom value>">
        <input name="token" type="hidden" value="<token>">
        <input name="file" type="file">
        ...
      </form>
    

</code>

找到的原因竟然是 那个空间不支持 我又新建一个空间就可以 奇葩。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

Statement:
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