我尝试在我的网站项目中使用:https://www.postmaster.io来满足我所有的最大运输需求。我在这里下载了示例php zip文件夹:https://github.com/postmaster/postmaster-php我遇到以下错误以及当前的代码。使用Postmaster的API请求者错误
好吧,所以首先,我有一个表单提交到处理页面。这看起来像下面这样:
<form method="post" action="/config/templates/checkout.php">
<input type="text" name="zip_code" id="zip_code" class="form-control" placeholder="Zip Code" />
<input type="submit" name="Submit1" value="Submit" />
</form>
然后我处理网页看起来是这样的:
if (isset($_POST['Submit1']))
{
require_once('../libraries/postMaster/Postmaster.php');
Postmaster::setApiKey("/* API key */");
$zip_code = $_POST['zip_code'];
echo $zip_code;
$result = Postmaster_Rates::get(array(
"from_zip" => "67124",
"to_zip" => $zip_code,
"weight" => 1.5,
"carrier" => "fedex",
));
var_dump($result);
}
它越来越来的代码$result = Postmaster_Rates::get(array(...
点并引发以下错误。我有一种感觉,虽然我找不到任何东西来支持我的想法,但它并没有像应该那样通过。
Fatal error: Uncaught exception 'InvalidData_Error' with message 'APIError 1000: Authentication Failed' in /home/www//config/libraries/postMaster/Postmaster/ApiRequestor.php:63
Stack trace:
#0 /home/www//config/libraries/postMaster/Postmaster/Rates.php(15):Postmaster_ApiRequestor->request('post', '/v1/rates', Array)
#1 /home/www/config/templates/checkout.php(19):Postmaster_Rates::get(Array)
#2 {main} thrown in /home/www//config/libraries/postMaster/Postmaster/ApiRequestor.php on line 63
(我删除我的主要网址从上面的错误代码。)
任何人在使用本系统,可以帮助我的经验吗?
有人吗?任何人都? – user2948950
不幸的是,Postmaster似乎没有记录他们的任何错误代码或失败请求响应,但您确定的异常似乎只是它所说的:您发送给Postmaster的api密钥正在被拒绝。再检查一遍? –