function sf_notifications_endpoint in Salesforce Suite 6.2
Same name and namespace in other branches
- 7.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 - hook_menu implementation
File
- sf_notifications/
sf_notifications.module, line 110
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;
}
// Needed for the reference to SObject in parse_message, otherwise it just
// seems to die when it tries to call new SObject()
require_once SALESFORCE_DIR_SOAPCLIENT . '/SforcePartnerClient.php';
$content = file_get_contents('php://input');
if (empty($content)) {
salesforce_api_log(SALESFORCE_LOG_SOME, 'SalesForce Notifications: Empty request.');
exit;
}
salesforce_api_log(SALESFORCE_LOG_ALL, 'New outbound message received from Salesforce. Contents: <pre>%content</pre>', array(
'%content' => print_r($content, TRUE),
));
$dom = new DOMDocument();
$dom
->loadXML($content);
if (empty($dom) || !$dom
->hasChildNodes()) {
salesforce_api_log(SALESFORCE_LOG_NONE, 'SalesForce Notifications: Failed to parse into DOM Document.
<pre>' . print_r($content) . '</pre>');
_sf_notifications_soap_respond('false');
exit;
}
$resultArray = _sf_notifications_parse_message($dom);
$ret = _sf_notifications_handle_message($resultArray);
// Sends SOAP response to SFDC
if ($ret) {
_sf_notifications_soap_respond('true');
}
else {
_sf_notifications_soap_respond('false');
}
exit;
}