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

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

问题描述

我正在尝试按照使用 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. 选择soap客户端,在本教程中,我们将假设使用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/connecting-through-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();
        }
?>

问候博蒂

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

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