function sf_notifications_endpoint in Salesforce Suite 7.2
Same name and namespace in other branches
- 6.2 sf_notifications/sf_notifications.module \sf_notifications_endpoint()
Menu callback for Salesforce notifications endpoint @todo Add authentication. see "Downloading the Salesforce.com Client Certificate" at http://www.salesforce.com/us/developer/docs/ajax/Content/sforce_api_ajax...
1 string reference to 'sf_notifications_endpoint'
- sf_notifications_menu in sf_notifications/
sf_notifications.module - Implements hook_menu.
File
- sf_notifications/
sf_notifications.module, line 130
Code
function sf_notifications_endpoint() {
// If the request is coming from outside the defined range of
// Salesforce IPs, then do not continue.
if (sf_notifications_allowed_ips() == FALSE) {
exit;
}
$content = file_get_contents('php://input');
if (empty($content)) {
salesforce_api_log(SALESFORCE_LOG_SOME, 'Salesforce Notifications: Empty request.');
drupal_exit();
}
salesforce_api_log(SALESFORCE_LOG_ALL, 'New outbound message received from Salesforce. Contents: <pre>%content</pre>', array(
'%content' => print_r($content, TRUE),
));
// If enabled, try to place the item in the notifications queue and exit. If not
// succesful, log it, and try to process directly.
if (variable_get('sf_notifications_use_queue', 0)) {
$queue = DrupalQueue::get('sf_notifications_queue');
if ($queue
->createItem($content)) {
salesforce_api_log(SALESFORCE_LOG_SOME, 'Outbound message from Salesforce pushed to queue.', array());
_sf_notifications_soap_respond('true');
drupal_exit();
}
else {
salesforce_api_log(SALESFORCE_LOG_ALL, 'Unable to store outbound message from Salesforce in queue, attempting to process directly. Contents: <pre>%content</pre>', array(
'%content' => print_r($content, TRUE),
), WATCHDOG_ERROR);
}
}
$ret = _sf_notifications_parse_handle_message($content);
// Sends SOAP response to SFDC.
if ($ret) {
_sf_notifications_soap_respond('true');
}
else {
_sf_notifications_soap_respond('false');
}
drupal_exit();
}