我按照prestashop教程,从服务器上收到 302 found error 。 关键是上帝,我拥有所有权限。
你有想法吗?
// Here we define constants /!\ You need to replace this parameters
define('DEBUG', true); // Debug mode
define('PS_SHOP_PATH', 'http://127.0.0.1/mystore/prestashop/'); // Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'); // Auth key (Get it in your Back Office)
require_once('./PSWebServiceLibrary.php');
// Here we make the WebService Call
try
{
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
// Here we set the option array for the Webservice : we want customers resources
$opt['resource'] = 'customers';
// Call
$xml = $webService->get($opt);
// Here we get the elements from children of customers markup "customer"
$resources = $xml->customers->children();
}
catch (PrestaShopWebserviceException $e)
{
// Here we are dealing with errors
$trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) echo 'Bad ID';
else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';
else echo 'Other error';
}
答案 0 :(得分:0)
HTTP状态代码302是重定向,因此不太可能由于证书问题。我最初的猜测是你需要在你的URL中添加/(或删除它)。当资源不以/结尾时,某些http服务器框架将重定向,因此,而不是:
GET /endPoint
Try
GET /endPoint/
另一种可能性是此资源需要身份验证,服务器会将您重定向到登录页面。如果你想知道发生了什么(而不是猜测),看一下302的响应标题。会有一个Location标题告诉你服务器要你去哪里。