Skip to content

Instantly share code, notes, and snippets.

@danieljpeter
Created May 4, 2012 00:25
Show Gist options
  • Save danieljpeter/2590661 to your computer and use it in GitHub Desktop.
Save danieljpeter/2590661 to your computer and use it in GitHub Desktop.
function getReportFolders($access_token) {
$arrReturn = array();
$query = "SELECT Id, DeveloperName FROM Folder WHERE Type='Report' AND DeveloperName != ''";
$url = "https://ssl.salesforce.com/services/data/v20.0/query?q=" . urlencode($query);
$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['records'] as $record) {
array_push($arrReturn, $record['DeveloperName']);
}
return $arrReturn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment