调用 magento soap api 立即过期

问题描述:

我正在尝试调用 magento api 以获取特定客户的详细信息.当我执行此调用时,我总是收到以下错误:

I'm trying to do a call to the magento api to get the details of a specific customer. When I do this call I always get the following error:

PHP Fatal error:  Uncaught SoapFault exception: [5] Session expired. Try to relogin. in     /var/www/magento-client/magento-customer.php:12
Stack trace:
/var/www/magento-client/magento-customer.php(12): SoapClient->__call('call', Array)
/var/www/magento-client/magento-customer.php(12): SoapClient->call('a1a6863c7dadd95...', 'customer.info', 3)
{main}
  thrown in /var/www/magento-client/magento-customer.php on line 12

我在后端有一个有效的 api 用户,后端的 api 会话超时设置为 9999999999999,我什至尝试覆盖 magento 核心代码中的 isSessionExpired 函数,但没有任何效果.

I have a valid api user in the backend, the api session timeout in the backend is set to 9999999999999, and I've even tried to override the isSessionExpired function in the magento core code, but nothing works.

代码如下:

$url = 'http://magentourl/api/soap/?wsdl';
$apiUser = "user";
$apiPass = "password";

$proxy = new SoapClient($url);

$sessionId = $proxy->login($apiUser, $apiPass);

// Get new customer info
var_dump($sessionId);
var_dump($proxy->call($sessionId, 'customer.info', 3));
die();

有人知道可能是什么问题吗?

Does anyone have any ideas what the problem could be?

如果您随请求一起发送标头,则会发生这种情况,请检查标头是否已发送.

This occurs if you send headers with the request, check if headers are sent.