我在尝试登录(认证)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", "[email protected]");
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。
创建一个外部php文件并访问magento登录
require_once('../ magentosite / app / Mage.php'); // Magento的路径umask(0); 法师:: app();
$ id = 1;
尝试{$ result = Mage :: getModel('customer / customer')-> setWebsiteId($ id)-> authenticate($ email,$ password); } catch(异常$ e){$ result = false; }
使用JSON将Android的用户名和密码发送到该php页面,并获取“结果”。
如果结果为“ true”,则数据库中存在用户名和密码。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句