How to list the Salesforce Meta Data using SOAP / PHP

In you php code initialize the PHP and Salesforce connection and use below code:

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;
}
?>

Written by 

Salesforce MVP | Lightning Champion | 16x Salesforce Certified | Application Architect | 6x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*