使用SOAP连接到Magento API [英] Connecting to Magento API with SOAP

查看:82
本文介绍了使用SOAP连接到Magento API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用tutorail通过Soap连接到magento API,但是已经卡住了吗?可以在我的服务器上安装SOAP,因为我可以浏览到?wsld并显示xml文件.

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 displays an xml file.

我已经在magento管理员网络服务中设置了用户和角色.

I've setup the user and role in magento admin webservices.

我对本教程中的两件事感到困惑

i'm confused by 2 things in the tutorial

  1. 选择一个肥皂客户端,在本教程中,我们将假定使用PHP SoapClient. 我在哪里找到它?
  2. 使用SOAP客户端登录

因此,我们创建一个简单的PHP脚本,该脚本允许我们通过SOAP登录Magento.这里的逻辑是,我们首先需要使用Magento SOAP URL作为参数来初始化一个新的SoapClient对象."

"So let's create a simple PHP-script that allows us to login into Magento through SOAP. The logic is here that we first need to initialize a new SoapClient object with as argument the Magento SOAP URL."

 // Magento login information 
 $mage_url = 'http://MAGENTO/api/?wsdl'; 
$mage_user = 'soap_user'; 
$mage_api_key = '********'; 
// Initialize the SOAP client 
$soap = new SoapClient( $mage_url ); 
// Login to Magento 
$session_id = $soap->login( $mage_user, $mage_api_key );

您在哪里创建此脚本-它是一个简单的php文件吗?以及您实际上如何拨打电话-您只是浏览到该电话吗?

http://blog.opensourcenetwork.eu/教程/guru/soap-with-magento-1

非常感谢

推荐答案

您将其放入新的空白文件中.将其另存为name.php并运行它在您的服务器上:

You put this into a new blank file. Save this as name.php und run this is on your server:

<?php
        $host = "127.0.0.1/magento/index.php"; //our online shop url
        $client = new SoapClient("http://".$host."/api/soap/?wsdl"); //soap handle
        $apiuser= "user"; //webservice user login
        $apikey = "key"; //webservice user pass
        $action = "sales_order.list"; //an action to call later (loading Sales Order List)
        try { 

          $sess_id= $client->login($apiuser, $apikey); //we do login


        print_r($client->call($sess_id, $action));
        }
        catch (Exception $e) { //while an error has occured
            echo "==> Error: ".$e->getMessage(); //we print this
               exit();
        }
?>

关于boti

这篇关于使用SOAP连接到Magento API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆