You need to make a cURL call using POST that passes the required fields as post fields.
The curl() function below will do this if you pass it:
$url = 'https://domain.com/SaveCart/{SessionID}';
With {SessionID} replaced by the the session ID and:
$fields[ 'first_name' ] = 'Bob';
$fields[ 'last_name' ] = 'Smith';
$fields[ 'city' ] = 'Seattle';
With Bob, Smith, and Seattle replaced with the relevant text;
Then just call the function as:
$result = curl( $url, $fields );
The URLify function below curl() is called by the curl() to transform $fields into the format required for POSTing.
function curl( $url, $fields = FALSE, $encode = TRUE, $tries = 1 ) {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
if ( ( $fields == FALSE ) ) {
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
} else {
if ( is_array( $fields ) ) {
$fields_string = URLify( $fields, $encode );
curl_setopt( $ch, CURLOPT_POST, count( $fields ) );
} else {
$fields_string = $fields;
curl_setopt( $ch, CURLOPT_POST, 1 );
}
curl_setopt( $ch, CURLOPT_POSTFIELDS, $fields_string );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
}
do {
$output = curl_exec( $ch );
$tries = $tries - 1;
if ( ( curl_errno( $ch ) <> FALSE ) AND ( $tries > 0 ) ) {
echo 'ERROR in curl: WILL RETRY AFTER 1 SECOND SLEEP! error number: ' . curl_errno( $ch ) . ' error : ' . curl_error( $ch ) . " url: $url";
sleep( 1 );
}
} while ( ( curl_errno( $ch ) <> FALSE ) AND ( $tries > 0 ) );
// Check if any error occurred
if ( curl_errno( $ch ) ) {
echo 'ERROR in curl: NO MORE RETRIES! error number: ' . curl_errno( $ch ) . ' error : ' . curl_error( $ch ) . " url: $url";
}
curl_close( $ch );
return $output;
}
This function is called by the curl() function:
function URLify( $arr, $encode = FALSE ) {
$fields_string = '';
foreach( $arr as $key => $value ) {
if ( $encode ) {
$key = urlencode( $key );
$value = urlencode( $value );
}
$fields_string .= $key . '=' . $value . '&';
}
$fields_string = substr( $fields_string, 0, ( strlen( $fields_string ) - 1 ) );
return $fields_string;
}