Skip to content

Instantly share code, notes, and snippets.

@jeremi
Forked from jmertic/gist:4348780
Created January 8, 2013 20:47
Show Gist options
  • Save jeremi/4487775 to your computer and use it in GitHub Desktop.
Save jeremi/4487775 to your computer and use it in GitHub Desktop.
// Let's add a new Email record
$parameters = array(
'session' => $sessionId,
'module' => 'Emails',
'name_value_list' => array(
array('name' => 'name', 'value' => 'email body'),
array('name' => 'from_addr', 'value' => '[email protected]'),
array('name' => 'to_addrs', 'value' => '[email protected]'),
array('name' => 'date_sent', 'value' => gmdate("Y-m-d H:i:s")),
array('name' => 'description', 'value' => 'This is an email created from a REST web services call'),
array('name' => 'description_html', 'value' => '<p>This is an email created from a REST web services call</p>'),
array('name' => 'parent_type', 'value' => '<<RelatedModuleName>>'),
array('name' => 'parent_id', 'value' => '<<RelatedModuleRecordId>>'),
),
);
$json = json_encode($parameters);
$postArgs = array(
'method' => 'set_entry',
'input_type' => 'JSON',
'response_type' => 'JSON',
'rest_data' => $json,
);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs);
// Make the REST call, returning the result
$response = curl_exec($curl);
// Convert the result from JSON format to a PHP array
$result = json_decode($response);
if ( !is_object($result) ) {
var_dump($result);
die("Error handling result set_entry Emails.\n");
}
if ( !isset($result->id) ) {
die("Error: {$result->name} - {$result->description}\n.");
}
// Get the newly created email id
$emailId = $result->id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment