我尝试登录(认证)magento客户时遇到问题.我无法找到使用电子邮件和密码登录客户的正确方法.那么,你能告诉我如何使用SOAP API在magento商店中进行身份验证或登录客户.
我试过这个代码如下所示
我试过这个代码如下所示
env.dotNet = false; env.xsd = SoapSerializationEnvelope.XSD; env.enc = SoapSerializationEnvelope.ENC; SoapObject request = new SoapObject(NAMESPACE,"login"); request.addProperty("username","xyz"); request.addProperty("apiKey","xyz"); env.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.debug = true; androidHttpTransport.call("",env); Object result = env.getResponse(); Log.d("sessionId",result.toString()); // making call to get list of customers String sessionId = result.toString(); request = new SoapObject(NAMESPACE,"customerCustomerInfo"); request.addProperty("sessionId",sessionId); request.addProperty("customerId","2032"); request.addProperty("email","abc@def.com"); request.addProperty("password","password"); env.setOutputSoapObject(request); androidHttpTransport.call(SOAP_ACTION,env); androidHttpTransport.debug = true; result = env.getResponse(); Log.d("Customer List",result.toString());
}
但它没有帮助我,所以有任何人可以解决我的问题.
谢谢….
解决方法
没有直接选项将客户登录到magento.从API检索的密码是hash_password,您无法检查密码是否相等.但您可以使用下面介绍的方法登录magento.
require_once( ‘../ magentosite /应用/ Mage.PHP’); // Magento之路
的umask(0);
法师::应用程式();
$id = 1;
尝试{$result = Mage :: getModel(‘customer / customer’) – > setWebsiteId($id) – > authenticate($email,$password);} catch(Exception $e){$result = false;}>使用JSON将用户名和密码从android发送到该PHP页面,并获得“结果”.>如果结果为“true”,则DB中存在用户名和密码.