亚马逊FPS CBUI返回URL验证 - PHP

时间:2012-08-07 17:58:47

标签: php amazon amazon-fps

我正在尝试运行PHP的亚马逊FPS快速入门指南,并且无法验证CBUI提供的返回网址。

这是网址:

http://local-screen.com/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/ReturnUrlVerificationSampleCode.php?tokenID=N1G9E5I7BH72563866UZ23YZ1X1AL9AZ2A9291Q1PKDATS8R7BLZ6Y7LEHY2QRHS&signatureMethod=RSA-SHA1&status=SC&signatureVersion=2&signature=WbBPFQku5BA67CR9vWr664eLNDahErYWZM6GrOYTnlDmLZf0rBm0XATrGPLgj5V94GsP0n%2BJ0uye%0A0MRZ3gastZX9M0cjbaPBcCjW1ydt%2BtCiatd%2BjQA6ZRs7XD%2BmWMqHVT3b4eY5WXKHHHQIvp4xLjJY%0AxuwtLf4MaYuiATtdnCY%3D&certificateUrl=https%3A%2F%2Ffps.sandbox.amazonaws.com%2Fcerts%2F090911%2FPKICert.pem%3FrequestId%3Dbjyk7pqb789b33qxg4h9lx8kn8ijplnc5pow0ycey00olslowmv&expiry=01%2F2018&callerReference=%241%24yo8s

这是我得到的错误:

Verifying return url signed using signature v2 .... 
Fatal error: Uncaught exception 'Amazon_FPS_SignatureException' with message 'Certificate could not be verified by the FPS service' in /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/SignatureUtilsForOutbound.php:103 Stack trace: #0 /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/SignatureUtilsForOutbound.php(50): Amazon_FPS_SignatureUtilsForOutbound->validateSignatureV2(Array, 'http://local-sc...', 'GET') #1 /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/ReturnUrlVerificationSampleCode.php(93): Amazon_FPS_SignatureUtilsForOutbound->validateRequest(Array, 'http://local-sc...', 'GET') #2 /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/ReturnUrlVerificationSampleCode.php(97): Amazon_FPS_ReturnUrlVerificationSampleCode::test() #3 {main} thrown in /home/content/85/9687085/html/wp-content/plugins/lclscrn_projects/amazon_fps/FPS/SignatureUtilsForOutbound.php on line 103

以下是获取变量并调用验证页面的函数:

public static function test() {

                $aws_access_key = self::$aws_access_key;
                $aws_secret_key = self::$aws_secret_key;

                $utils = new Amazon_FPS_SignatureUtilsForOutbound($aws_access_key, $aws_secret_key);

                /* Verification of an return url signed using signature version 2.*/

                // New parameters sent in return url signed using signature v2
                $params["certificateUrl"] = self::$certificate_url;
                $params["signature"] = self::$signature;
                $params["signatureMethod"] = self::$signature_method;
                $params["signatureVersion"] = self::$signature_version;

                // foreach ($params as $param) {
                //         echo $param;
                //         echo '<br/><br/>';
                // }
                // echo self::$return_url;
                // return;


                $urlEndPoint = self::$return_url; //Your return url end point. 
                print "Verifying return url signed using signature v2 ....\n";
                //return url is sent as a http GET request and hence we specify GET as the http method.
                //Signature verification does not require your secret key
                print "Is signature correct: " . $utils->validateRequest($params, $urlEndPoint, "GET") . "\n";
    }

我也有foreach循环的输出,如果有人需要它我可以PM。我只是不明白为什么我无法验证这个网址。任何帮助将不胜感激。

尼克

1 个答案:

答案 0 :(得分:0)

我也在使用亚马逊的PHP示例代码,并且遇到了完全相同的错误消息。

<强>解决方案

要求1:您在VerifySignature请求中传递的HttpParameters的值必须与Amazon的UI传递给您的返回网址的顺序相同。因此,不要像亚马逊的示例代码那样手动获取每个GET参数,而只需使用$_GET对象作为$parametersSignatureUtilsForOutbound.php变量的值。

要求2 :您需要在互联网上可以访问的框中进行测试。如果您从localhost进行测试,则始终会收到此错误。