Connecting to Magento API with SOAP

前端 未结 5 2106
悲&欢浪女
悲&欢浪女 2021-01-12 09:45

I\'m trying to follow a tutorail on connecting to magento API with Soap, but am stuck already ? SOAP seems to be installed on my sever as i can browse to the ?wsld and it di

5条回答
  •  长发绾君心
    2021-01-12 10:22

    As per your question i will tel you simple steps, follow those steps then you wii get result as we require. 1. Login to Magento admin panel then navigate to system-->webservices-->SOAP RPC Roles create SOAP RPC roles 2. Navigate to system-->webservices-->SOAP RPC users create SOAP RPC user map this user with roles. 3. Create one PHP file name it as magentoapi.php inside xampp-->htdocs-->folder(project name). 4. Here I am giving you one example, how to get customer Info. 5. Open magentoapi.php file create one function name it as customerInfo

    Below is the code:

        function customerInfo($api_url, $api_user, $api_pwd) {
    
            $websites = '' . $api_url . "/index.php/api/soap/?wsdl";
            try {
                $client = new SoapClient($websites);
                $session = $client->login($api_user, $api_pwd);
    
                $result = $client->call($session, 'customer.info', '1');
                print_r($result);
            } catch (\SoapFault $e) {
                echo $e->getMessage();
            }
        }
    

    Here, $api_url is your store url,$api_user= api user name, $api_pwd = api password pass this value to the customerInfo function. We will get complete information about a particular customer

    Do same thing for all functions Here is the API reference URL http://devdocs.magento.com/guides/m1x/api/soap/customer/customer.list.html

    Finally run the below URL in browser you will get results

    http://localhost/yourprojectname/magentoapi.php?functionName=customerLogout&store_url=http://127.0.0.1/magento19&api_username=magento&api_key=123456

提交回复
热议问题