4

Remote authentication from PHP

For all of you PHP lovers, here is an example of how you can use Zendesk's Remote Authentication API to authenticate users in your own database via PHP.

 <?

/*
* Remote authentication stub for PHP
*
* This is meant as a template for your own customization. You can identify the user anyway you like,
* integrate it into your intranet, web app or similar.
*
* You may call this script directly or have Zendesk redirect to it using the
* Remote Authentication URL.
*
*/

/* The following values should be set from your source of information */
$sFullName = "Firstname Lastname";
$sEmail = "youremail@yourdomain.com";
$sExternalID = "";
$sOrganization = "";

/* Insert the Autentication Token here */
$sToken = "52713bf24cc564c72asd249feb7de52de341195c";

/* Insert your account prefix here. If your account is yoursite.zendesk.com: */
$sUrlPrefix = "yoursite";

/* Build the message */
$sTimestamp = isset($_GET['timestamp']) ? $_GET['timestamp'] : time();
$sMessage = $sFullName.$sEmail.$sExternalID.$sOrganization.$sToken.$sTimestamp;
$sHash = MD5($sMessage);

$sso_url = "http://".$sUrlPrefix.".zendesk.com/access/remote/?name=".$sFullName."&email=".$sEmail."&external_id=".$sExternalID."&organization=".$sOrganization."&timestamp=".$sTimestamp."&hash=".$sHash;

header("Location: ".$sso_url);

?>

19 comments

Please sign in to leave a comment.