可能重复:
Debugging PHP SOAP call
这是我第一次使用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 } ?>
答案 0 :(得分:0)