2013-02-04 39 views
2

可能重复:
Debugging PHP SOAP call不能使用类型为stdClass的对象作为数组的Magento

这是我第一次使用SOAP API和我准备这个剧本,但我得到了
“不能使用类型为stdClass的对象作为数组”错误,请告诉我正确的方法来检索数据

<?php 
// Magento login information 
$mage_url = 'http://localhost/magento//index.php/api/V2_soap?wsdl=1'; 
$mage_user = 'rohit'; 
$mage_api_key = '1234567890'; 
// Initialize the SOAP client 
$soap = new SoapClient($mage_url); 
// Login to Magento 
$session_id = $soap->login($mage_user, $mage_api_key); 
print_r($session_id); 
?> 


<?php 
$resources = $soap->resources($session_id); 
if(is_array($resources) && !empty($resources)) { ?> 
<?php foreach($resources as $resource) { ?> 
<h1><?php echo $resource['title']; ?></h1> 
Name: <?php echo $resource['name']; ?><br/> 
Aliases: <?php echo implode(',', $resource['aliases']); ?> 
<table> 
    <tr> 
     <th>Title</th> 
     <th>Path</th> 
     <th>Name</th> 
    </tr> 
    <?php foreach($resource['methods'] as $method) { ?> 
    <tr> 
     <td><?php echo $method['title']; ?></td> 
     <td><?php echo $method['path']; ?></td> 
     <td><?php echo $method['name']; ?></td> 
     <td><?php echo implode(',', $method['aliases']); ?></td> 
    </tr> 
    <?php } ?> 
</table> 
<?php } ?> 
<?php } ?> 

回答

相关问题