2011-05-27 36 views
5

我正在寫一個移動設備和magento之間的通信的Web服務,我使用Magento提供的SOAP webservices,但是,我迷失在用戶身份驗證,我需要進行身份驗證我的系統用戶(不是api用戶)。有什麼線索嗎?Magento SOAP WebService - >用戶登錄

+0

如果我理解正確,您想使用「admin」的佔了Web服務進行身份驗證?可能會提供一些幫助:http://www.yireo.com/tutorials/magento/magento-programming/629-connecting-to-magento-with-soap-part-1 – B00MER 2011-05-27 15:41:24

+3

不,這就是我已經做的,我想要從該「管理」帳戶驗證「用戶」帳戶,希望您明白這一點。 – 2011-05-27 23:22:15

+0

在相應的手冊中沒有指出apis的基本差異似乎是一種傳統。 – John 2015-02-20 13:59:52

回答

1

您不能使用SOAP Api來記錄magento中的用戶帳戶,因爲它不支持該功能,您必須以其他方式處理它,也許會覆蓋Mage Customer中名爲AccountController.php的控制器文件。

嘗試添加一個可以使用JSON變量與服務器進行通信的新方法。

-1

不,你不能那樣做。如果您可以通過FTP訪問文件,那麼您可以使用數據庫配置文件的get_file_content,然後從外部源連接到數據庫並執行用戶訪問檢查。

適用於您自己承擔風險。可能它無效。但你可以試試!

1

您可以使用REST API來驗證客戶身份。 http://www.magentocommerce.com/api/rest/introduction.html

這種做法似乎更加方便,因爲您可能會收到一個產品列表與登錄的客戶應用類別規則(比方說,通過客戶羣應用)。 SOAP API不提供此類功能(您只能以管理員用戶身份接收產品列表)。

1

使用此

$mageFilename = 'app/Mage.php'; 
require_once $mageFilename; 
$app = Mage::app('default'); 
Mage::app(); 
$user = "[email protected]"; 
$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); 
       }