Created
May 3, 2012 23:34
-
-
Save danieljpeter/2590400 to your computer and use it in GitHub Desktop.
php script to get the object names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getObjectLists($access_token) { | |
| //this function returns an assoc array. The value "standard" is an array of the std objects, "custom" is an array of the custom objects | |
| $arrReturn = array(); | |
| $arrReturn['standard'] = array(); | |
| $arrReturn['custom'] = array(); | |
| $url = "https://ssl.salesforce.com/services/data/v24.0/sobjects/"; | |
| $curl = curl_init($url); | |
| curl_setopt($curl, CURLOPT_HEADER, false); | |
| curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($curl, CURLOPT_HTTPHEADER, array("Authorization: OAuth $access_token")); | |
| $json_response = curl_exec($curl); | |
| curl_close($curl); | |
| $response = json_decode($json_response, true); | |
| foreach ((array) $response['sobjects'] as $record) { | |
| if ($record['custom'] == true) { | |
| array_push($arrReturn['custom'], $record['name']); | |
| } else { | |
| array_push($arrReturn['standard'], $record['name']); | |
| } | |
| } | |
| return $arrReturn; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment