Magento 1.7.x 获取获取全部API

$client = new SoapClient('http://magento.vfeelit.com/api/v2_soap/?wsdl');
	
$session = $client->login('vfeelit', '1234567890');
$result = $client->resources($session);
print_r($result);

数组打印:

Array
(
    [0] => stdClass Object
        (
            [title] => Store API
            [name] => core_store
            [aliases] => Array
                (
                    [0] => store
                )

            [methods] => Array
                (
                    [0] => stdClass Object
                        (
                            [title] => Retrieve store list
                            [path] => core_store.list
                            [name] => list
                            [aliases] => Array
                                (
                                    [0] => store.list
                                )

                        )

                    [1] => stdClass Object
                        (
                            [title] => Retrieve store data
                            [path] => core_store.info
                            [name] => info
                            [aliases] => Array
                                (
                                    [0] => store.info
                                )

                        )

                )

        )

    [1] => stdClass Object

输出的数组元素都是一个stdClass。看看和V1的差别:

$client = new SoapClient('http://magento.vfeelit.com/api/soap/?wsdl');
	
$session = $client->login('vfeelit', '1234567890');
$result = $client->resources($session);
print_r($result);

数组打印:

Array
(
    [0] => Array
        (
            [title] => Store API
            [description] => 
            [name] => core_store
            [aliases] => Array
                (
                    [0] => store
                )

            [methods] => Array
                (
                    [0] => Array
                        (
                            [title] => Retrieve store list
                            [description] => 
                            [path] => core_store.list
                            [name] => list
                            [aliases] => Array
                                (
                                    [0] => store.list
                                )

                        )

                    [1] => Array
                        (
                            [title] => Retrieve store data
                            [description] => 
                            [path] => core_store.info
                            [name] => info
                            [aliases] => Array
                                (
                                    [0] => store.info
                                )

                        )

                )

        )

    [1] => Array

v1 API输出全部使用数组组织,v2 API是使用stdClass包装,说明版本1 和 2不兼容。

永久链接:http://blog.ifeeline.com/560.html
原创文章,转载务必保留出处。