Home PHP How to list the Salesforce Meta Data using SOAP / PHP

How to list the Salesforce Meta Data using SOAP / PHP

In you php code initialize the PHP and Salesforce connection and use below code:
[php]
try
{
//salesforce login and wsdl
if (isset($client))
{
// Retrieve all the objects in the organization
$result = $client->describeGlobal();

// Cycle through each object
foreach ($result->types as $objectType)
{

// Retrieve the object definition
$resultObject = $client->describeSObject($objectType);

echo “<strong><u>” . $objectType . “</u></strong><br />\n”;

// Cycle through each field

foreach ($resultObject->fields as $field)
{
echo $field->name . “<br />\n”;

}
}
}

}
catch (exception $e)
{
// This is reached if there is a major problem in the data or with
// the salesforce.com connection. Normal data errors are caught by
// salesforce.com
echo ‘<pre>’ . print_r($e, true) . ‘</pre>’;
return false;
exit;
}
?>
[/php]

You may also like

Leave a Comment