PHP Integration Kit

Sample code

The application should capture the resumePath upon a GET request to this URL with code similar to the following:

 <?php
    # Use and instantiate an agent
    use pingidentity\opentoken\agent;
    $myagent = new Agent();

    $resumePath = $_GET['resume'];
    $returnUrl = "https://<SERVER_NAME>:9031/" . $resumePath;

    # After the user has authenticated, an OpenToken needs to be
    # generated with the userId and sent back to the previously
    # captured resumePath.

    $myvalues = array(TOKEN_SUBJECT => $userInfo["userid"],
    AUTHN_CTX_ATTRIBUTE_NAME => $userInfo[AUTHN_CTX_ATTRIBUTE_NAME]);

    $queryParam = $myagent->writeTokenToHTTPResponse($myvalues);
    if ($queryParam)
    {
        if (strpos($returnUrl, "?") == FALSE)
        {
           $returnUrl = $returnUrl . "?";
        }
        $returnUrl = $returnUrl . $queryParam;
    }
      header("Location: " . $returnUrl);
 ?>