Qiniuyun callback verification failed

after going through the official sdk and testing Qiniuyun, the callback verification always fails, and the true TM is speechless.

get token:

/**
     * token
     */
    public function fetchUploadToken()
    {
        // Auth
        $auth = new Auth($this->accessKey, $this->secretKey);
        $policy = [
            "callbackUrl" => "http:///acceptQiniuUploadCallback",
            "callbackBody" => "{"key":"$(key)","hash":"$(etag)","fsize":$(fsize),"bucket":"$(bucket)"}",
            "callbackBodyType" => "application/json"
        ];
        $upToken = $auth->uploadToken($this->bucket, null, $this->expires, $policy, true);

        echo $upToken;
    }

uploaded:

public function uploadFileToQiniu()
{
    $uploadToken = $_POST["uploadToken"];
    $uploadMgr = new UploadManager();
    list($ret, $err) = $uploadMgr->put($uploadToken, null, "test qiniu upload");

    if ($err !== null) {
        var_dump($err);
    } else {
        var_dump($ret);
    }
}

success, is returned for PS: upload, that is, upload is fine.

callback method:

public function acceptQiniuUploadCallback()
    {
        $auth = new Auth($this->accessKey, $this->secretKey);
        //body
        $callbackBody = file_get_contents("php://input");
        //contentType
        $contentType = "application/x-www-form-urlencoded";
        //
        $authorization = $_SERVER["HTTP_AUTHORIZATION"];
        //url:http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html
        $url = "http:///acceptQiniuUploadCallback";
        $isQiniuCallback = $auth->verifyCallback($contentType, $authorization, $url, $callbackBody);

        if ($isQiniuCallback) {
            $resp = array("ret" => "success");

        } else {
            $resp = array("ret" => "failed");
        }

        echo json_encode($resp);
    }

the parameters brought by Qiniu Cloud received are:

callbackBody:{\"key\":\"Fm2SqeglnKIi8UDYJ7_WhhR8fybG\",\"hash\":\"Fm2SqeglnKIi8UDYJ7_WhhR8fybG\",\"fsize\":17,\"bucket\":\"test\"}",
authhorization:
QBox KhMpusItBI66r4HjARLLeLrACyq0CFWVhltvxZRQ:PGtDDftzjgB4MFW5A5LF_5pXgpc=

validation just fails, that is, this line:

$isQiniuCallback = $auth->verifyCallback($contentType, $authorization, $url, $callbackBody);

the total TM returns false,. I don"t know if anyone else has encountered it. It"s a shit-like document, and the test can"t pass directly. And there"s no wrong hint. Is there any brother dei, who has encountered a similar situation to take a look at it? thank you!

Mar.16,2021

change the request header to application/json, which is caused by the inconsistency between the request header for generating signature and your request header

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46bd0-44bce.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46bd0-44bce.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?