使用SOAP API的android magento客户登录(身份验证)

Sam*_*nga 6 android soap magento

我尝试登录(认证)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());
Run Code Online (Sandbox Code Playgroud)

}

但它没有帮助我,所以有任何人可以解决我的问题.

谢谢....

Rem*_*yde 6

没有直接选项将客户登录到magento.从API检索的密码是hash_password,您无法检查密码是否相等.但您可以使用下面介绍的方法登录magento.

  1. 创建一个外部php文件并访问那里的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; }

  2. 使用JSON将用户名和密码从android发送到该php页面,并获得"结果".

  3. 如果结果为"true",则DB中存在用户名和密码.