Magento SOAP登录错误
我已经将Magento SOAP api配置为与我的android应用程序连接,客户可以从android应用程序登录到Magento。我面临的问题是,当我发送请求时,它会显示错误-“会话已过期” 这是我的API.php文件Magento SOAP登录错误,magento,soap,Magento,Soap,我已经将Magento SOAP api配置为与我的android应用程序连接,客户可以从android应用程序登录到Magento。我面临的问题是,当我发送请求时,它会显示错误-“会话已过期” 这是我的API.php文件 <?php // app/code/local/Anaqa/Customapimodule/Model/Login/Api.php class Anaqa_Customapimodule_Model_Customerlogin_Api extends Mage
<?php
// app/code/local/Anaqa/Customapimodule/Model/Login/Api.php
class Anaqa_Customapimodule_Model_Customerlogin_Api extends Mage_Api_Model_Resource_Abstract {
public function customerEntry($email) {
#Mage::app()->setCurrentStore($website);
# // Init a Magento session. This is super ultra important
#Mage::getSingleton('core/session');
// $customer Mage_Customer_Model_Customer
// We get an instance of the customer model for the actual website
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
// Load the client with the appropriate email
$customer->loadByEmail($email);
return $customer;
}
/*
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient('http://magentohost/api/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'product.list');
$client->endSession($session);
Mage::app()->setCurrentStore($website);
// Init a Magento session. This is super ultra important
Mage::getSingleton('core/session');
// $customer Mage_Customer_Model_Customer
// We get an instance of the customer model for the actual website
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
// Load the client with the appropriate email
$customer->loadByEmail($email);
// Get a customer session
$session = Mage::getSingleton('customer/session');
$session->loginById($customer->getId());
if ($session->isLoggedIn()) {
return $session->getSessionId();
} else {
return null;
}
} */
}
我将使用客户/会话模型访问客户
$sessionCustomer = Mage::getSingleton('customer/session');
if($sessionCustomer->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
这里的折痕是为了让magento访问会话数据,它需要知道客户已登录,否则您将无法将客户数据与会话数据一起返回 我将使用客户/会话模型访问客户
$sessionCustomer = Mage::getSingleton('customer/session');
if($sessionCustomer->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
这里的折痕是为了让magento访问会话数据,它需要知道客户已登录,否则您将无法将客户数据与会话数据一起返回