Skip to content

Instantly share code, notes, and snippets.

@zargyle
Last active June 4, 2019 10:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zargyle/52621165e3f7e1edbd14 to your computer and use it in GitHub Desktop.
Save zargyle/52621165e3f7e1edbd14 to your computer and use it in GitHub Desktop.
Salesforce Delegated Authentication PHP Web Service
<?php
require_once "nusoap/lib/nusoap.php";
//create the server.
$server = new soap_server;
//set configuration for the web service's WSDL.
$server->configureWSDL('authentication.soap.sforce.com','urn:authentication.soap.sforce.com','',"document");
//register an action called Authenticate.
$server->register(
'Authenticate',
array('username'=>'xsd:string','password'=>'xsd:string','sourceIp'=>'xsd:string'),
array('Authenticated'=>'xsd:boolean')
);
function Authenticate($username, $password, $sourceIp) {
try{
$valid = false;
//Authenticate request here
return $valid;
} catch (Exception $e) {
//write error message a log file $e->getMessage();
return false;
}
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment