So I can't for the life of me figure out a decent way to format some data that a soap client is spitting at me.
I am pulling the contacts from an email system. The SOAP API we use gives it to me in an array. here is an example of the output.
( [id] => 10868208 [firstname] => name [lastname] => last [nickname] => [email] => [favorite] => 0 [email2] => [email3] => [h_phone] => [b_phone] => [mobile_phone] => XXX XXX XXXX [fax] => [h_street1] => [h_street2] => [h_city] => [h_state] => [h_zip] => [h_country] => [b_street1] => [b_street2] => [b_city] => [b_state] => [b_zip] => [b_country] => [label] => [job_title] => [company] => [other_phone] => [other_street1] => [other_street2] => [other_city] => [other_state] => [other_zip] => [other_country] => [website] => [blog] => [other_website] => [aol_account] => [yahoo_account] => [google_account] => [icq_account] => [other_account] => )
These are seperated by [n] => stdClass Object where n= ascending number per entry.
Anyone have any decent ideas about how to organize this data, so that I can output it into a table format or something of the like?
Thanks in advance,
Harry
Formatting SOAP output
Moderator: General Moderators
-
Richardsonh
- Forum Newbie
- Posts: 2
- Joined: Sun Dec 27, 2009 11:25 am
[solved] Formatting SOAP output
So after more tinkering here's what I found. It was returning the information as an Object, inside of an array, inside of a keyed array. So I stripped off the top layer, and it's just an array of objects.
Here's the code.
hope this helps if anyone comes across the same thing.
Here's the code.
Code: Select all
<?php
$client = new SoapClient('https://email.rackspace.com/mail6/ext/soap/soap_server.php?wsdl');
$res = $client->__soapCall('GetUserContactsFull',
array('ResellerUsername' => '*****',
'ResellerPassword' => '*******',
'HostName' => '&&&&&',
'UserID' => '******'));
$array=$res['contactList'];
for($i=0; $i<count($array); $i++)
{
echo "<table border='0' style='width=50%' cellpadding=3 cellspacing=3>";
echo "<tr>";
echo "<td>";
echo "ID";
echo "</td>";
echo "<td>";
echo $array[$i]->id;
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "First Name";
echo "</td>";
echo "<td>";
echo $array[$i]->firstname;
echo "</td>";
echo "</tr>";
}
?>