Magento SOAP WebService - >用户登录

时间:2011-05-27 12:57:19

标签: php web-services soap magento

我正在编写一个用于移动设备和magento之间通信的Web服务,我正在使用Magento提供的SOAP Web服务,但是,我在用户身份验证时丢失了,我需要验证我的系统用户(不是api用户) )。对此有什么疑问吗?

4 个答案:

答案 0 :(得分:1)

您不能使用SOAP Api来记录magento中的用户帐户,因为它不支持该功能,您必须以另一种方式处理它,可能会覆盖名为AccountController.php的Mage Customer中的控制器文件。

尝试添加一个可以使用JSON变量与服务器通信的新方法。

答案 1 :(得分:1)

您可以使用REST api对客户进行身份验证。 http://www.magentocommerce.com/api/rest/introduction.html

这种方法似乎更方便,因为您可能会收到一个产品列表,其中包含已登录客户的应用目录规则(假设由客户组应用)。 SOAP API不提供此类功能(您只能以管理员用户身份接收产品列表)。

答案 2 :(得分:1)

使用此

$mageFilename = 'app/Mage.php';
require_once $mageFilename;
$app = Mage::app('default'); 
Mage::app();
$user = "snjha77@gmail.com";
$pass = "admin123";
$session = Mage::getSingleton( 'customer/session' );
    Mage::app()->getStore()->setWebsiteId(1);
    try
    {
        $session->login( $user, $pass);
        $customer = $session->getCustomer();
        //echo "valid";
        $userID = $session->getCustomer()->getId();
    $return_array['customer_id'] = $userID;
        $return_array['status'] = 1;
        $return_array['message'] = "Login is valid";
        echo json_encode($return_array);
        } catch( Exception $e ) {
            $return_array['status']= 0;
        $return_array['message']="Login is invalid";
        echo json_encode($return_array);
              }

答案 3 :(得分:-1)

不,你不能这样做。如果您可以通过FTP访问文件,那么您可以获取数据库配置文件的get_file_content,然后从外部源连接到数据库并执行用户访问检查。

自行承担风险。可能无效。但你可以试试!