我正在尝试使用tutorail通过Soap连接到magento API,但是已经被卡住了吗? SOAP似乎已安装在我的服务器上,因为我可以浏览到?wsld并显示xml文件。
我已经在magento admin网络服务中设置了用户和角色。
我对本教程中的两件事感到困惑
“因此,让我们创建一个简单的PHP脚本,使我们可以通过SOAP登录Magento。这里的逻辑是,我们首先需要使用Magento SOAP URL作为参数来初始化一个新的SoapClient对象。”
// 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/tutorials/guru/connecting-through-soap-with-magento-1
提前谢谢了
最佳答案
您将此放入一个新的空白文件。将其另存为name.php并运行在您的服务器上:
<?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
关于magento - 使用SOAP连接到Magento API,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8139128/