获得Magento全部Api方法

获取Magento全部Api方法的代码
其中的ApiUser和ApiKey为网站后台添加的WebService用户的连接信息,换成你自己的。
Magento官方文档见:Magento core Api

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>获得全部的Magento Api方法 www.hellokeykey.com</title>
<style type="text/css">
.box1{ border:2px solid #000; margin-bottom:10px; padding:10px;}
.box1 .path{ margin-bottom:10px; border-bottom-style:dashed; border-bottom-color:#000000; border-bottom-width:1px;}
</style>
</head>
<body>
    <?php
    $client = new SoapClient('http://youwebsite/api/soap/?wsdl');
    $session = $client->login('ApiUser', 'ApiKey');
    $result = $client->resources($session);
    foreach($result as $k1=>$v1)
    {
        echo '<div class="box1"><dl>';
        echo '<dt>Title:</dt><dd>'.$v1[title].'</dd>';
        echo '<dt>Name:</dt><dd>'.$v1[name].'</dd>';
        echo '<dt>methods:</dt><dd>';
        if(count($v1[methods])){
            echo '<ul>';
            foreach($v1[methods] as $k2=>$v2)
            {
                echo '<li>Title:'.$v2[title].'</li>';
                echo '<li>Name:'.$v2[name].'</li>';
                echo '<li class="path">Path:'.$v2[path].'</li>';
            }
            echo '</ul></dd>';
        }
        echo '</dl></div>';
    }
    ?>
</body>
</html>

 

posted @ 2014-01-28 10:59  狂热的猴子  阅读(1039)  评论(0编辑  收藏  举报