About triggering asynchronous processing {"error": "badtoken "}

Source: Internet
Author: User
Authorization code ...20.authorization code ...20.authorization code ..20.gitwiduu.u.qiniudn.comweidu.png? ImageView2w200h200 | saveasZ2l0d2lkdXU6d2lkdXUucG5nsignKUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR: oLnyNAFkj7gs6a0LyLJ581bCS_Q {generation...
// The code is like this. I want to process image persistence asynchronously.
function makeUrl($url,$bucket,$savekey,$ak="KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR",$sk="D-K57TE5hPe3krexftxLWFKmL2xbQEKA-mtkrUfB"){    $find = array('+', '/');    $replace = array('-', '_');    $encode = str_replace($find,$replace,base64_encode("$bucket:$savekey"));    $url    = $url."|saveas/".$encode;    $sha1   = hash_hmac('sha1',$url,$sk,true);    $sign   = $ak.":".(str_replace($find,$replace,base64_encode($sha1)));    $data   = $url."/sign/".$sign;    return $data;}echo makeUrl("gitwiduu.u.qiniudn.com/weidu.png?imageView/2/w/200/h/200","gitwiduu","widuu.png");
// The output url is

Gitwiduu.u.qiniudn.com/weidu.png? ImageView/2/w/200/h/200 | saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR: oLnyNAFkj7gs6a0LyLJ581bCS_Q =

// Splice params
//bucket=gitwiduu&key=weidu.png&fops=imageView/2/w/200/h/200;saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:oLnyNAFkj7gs6a0LyLJ581bCS_Q=&notifyURL=http://localhost/
function url_safe_baseencode($str) // URLSafeBase64Encode{    $find = array('+', '/');    $replace = array('-', '_');    return str_replace($find, $replace, base64_encode($str));}function sign1($data,$ak="KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR",$sk="D-K57TE5hPe3krexftxLWFKmL2xbQEKA-mtkrUfB"){    $sign = hash_hmac('sha1', $data, $sk, true);    return $ak.':'.url_safe_baseencode($sign);}

// According to the official document path? Query \ nbody encrypted output result

echo sign1("/pfop\nbucket=gitwiduu&key=weidu.png&fops=imageView/2/w/200/h/200;saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:oLnyNAFkj7gs6a0LyLJ581bCS_Q=&notifyURL=http://localhost/");
// Get Authorization token // The output token is KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR: 8nodNoJ7A8QE59UNrlMXSs-2ATY = then php curl the experiment won't work and then experiment in linux
curl -d "bucket=gitwiduu&key=weidu.png&fops=imageView/2/w/200/h/200;saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:oLnyNAFkj7gs6a0LyLJ581bCS_Q=&notifyURL=http://localhost/" -H  "Content-Type: application/x-www-form-urlencoded" -H "Authorization: QBox KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:8nodNoJ7A8QE59UNrlMXSs-2ATY=" http://api.qiniu.com/pfop
// Or to the http://api.qiniu.com/pfop/ is returned json appear {"error": "bad token"} "where is the error?

Reply content:
// The code is like this. I want to process image persistence asynchronously.
function makeUrl($url,$bucket,$savekey,$ak="KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR",$sk="D-K57TE5hPe3krexftxLWFKmL2xbQEKA-mtkrUfB"){    $find = array('+', '/');    $replace = array('-', '_');    $encode = str_replace($find,$replace,base64_encode("$bucket:$savekey"));    $url    = $url."|saveas/".$encode;    $sha1   = hash_hmac('sha1',$url,$sk,true);    $sign   = $ak.":".(str_replace($find,$replace,base64_encode($sha1)));    $data   = $url."/sign/".$sign;    return $data;}echo makeUrl("gitwiduu.u.qiniudn.com/weidu.png?imageView/2/w/200/h/200","gitwiduu","widuu.png");
// The output url is

Gitwiduu.u.qiniudn.com/weidu.png? ImageView/2/w/200/h/200 | saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR: oLnyNAFkj7gs6a0LyLJ581bCS_Q =

// Splice params
//bucket=gitwiduu&key=weidu.png&fops=imageView/2/w/200/h/200;saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:oLnyNAFkj7gs6a0LyLJ581bCS_Q=&notifyURL=http://localhost/
function url_safe_baseencode($str) // URLSafeBase64Encode{    $find = array('+', '/');    $replace = array('-', '_');    return str_replace($find, $replace, base64_encode($str));}function sign1($data,$ak="KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR",$sk="D-K57TE5hPe3krexftxLWFKmL2xbQEKA-mtkrUfB"){    $sign = hash_hmac('sha1', $data, $sk, true);    return $ak.':'.url_safe_baseencode($sign);}

// According to the official document path? Query \ nbody encrypted output result

echo sign1("/pfop\nbucket=gitwiduu&key=weidu.png&fops=imageView/2/w/200/h/200;saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:oLnyNAFkj7gs6a0LyLJ581bCS_Q=&notifyURL=http://localhost/");
// Get Authorization token // The output token is KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR: 8nodNoJ7A8QE59UNrlMXSs-2ATY = then php curl the experiment won't work and then experiment in linux
curl -d "bucket=gitwiduu&key=weidu.png&fops=imageView/2/w/200/h/200;saveas/Z2l0d2lkdXU6d2lkdXUucG5n/sign/KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:oLnyNAFkj7gs6a0LyLJ581bCS_Q=&notifyURL=http://localhost/" -H  "Content-Type: application/x-www-form-urlencoded" -H "Authorization: QBox KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR:8nodNoJ7A8QE59UNrlMXSs-2ATY=" http://api.qiniu.com/pfop
// Or to the http://api.qiniu.com/pfop/ is returned json appear {"error": "bad token"} "where is the error?

1. for manual persistentOps persistence, refer:http://segmentfault.com/q/1010000000331820
2. Actually, you don't need to use persistence. You can use saveas. After reading it, the obtained saveas url is correct.

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.