function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ethanoneethanone 

Using getDeleted with phptoolkit and curl

I'm trying to use phptoolkit to return the deleted records, but I can't seem to make getDeleted work.

The examples are using a different method than I've used in the past:
$getDeletedResponse = $mySforceConnection->getDeleted('Lead', $startTime, $endTime);
I've used curl for my standard queries, but it doesn't seem to work for getDeleted. Since I didn't need to create a connection object when using curl, i'm not sure how to do that with my session variables. Further, the session variables seem to be renamed (I think I'm using an older version).

Below is my getDeleted function using curl, please let me know what I"m doing wrong. Thanks in advance.
function SFgetDeleted($obj, $then, $now){
	$access_token = $_SESSION['access_token'];
    $instance_url = $_SESSION['instance_url'];
    
    if (!isset($access_token) || $access_token == "") {
    	die("Error - access token missing from session!");
    }
    if (!isset($instance_url) || $instance_url == "") {
        die("Error - instance URL missing from session!");
	}
	
	$url = "$instance_url/services/data/v33.0/getDeleted?sObjectType=".urlencode($obj)."&startDate=".urlencode($then)."&endDate=".urlencode($now);
	echo $url;
    $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);
    return $response;
}