in SampleIntegrations/SampleWebhooks/PHP/WebhookModifyEmailAfterUserDeactivation/webhook_deactivation_mod_user.php [58:82]
function modify_user_email_address($id_user, $new_email_address, $api_access_token) {
// Create and populate the curl object
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://graph.workplace.com/" . $id_user);
curl_setopt($ch, CURLOPT_POST, 1);
$fields = array(
"email" => $new_email_address
);
$fields_string = json_encode($fields);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/json',
'User-Agent:GithubRep-WebHookSecurityUserDeactivation',
'Authorization:Bearer ' . $api_access_token
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Send the curl request and receive the results
$server_output = curl_exec($ch);
curl_close ($ch);
logging_to_txt_file("Modifying user " . $id_user . " - New email: " . $new_email_address);
// We return the results from server
return $server_output;
}