Account Linking

In order to implement the Linking API using the SDK, the developer must use the controller class AccountLinkingController and pass a callback to onGetUserId. The callback receives a GetUserIdRequest object and returns a GetUserIdResponse.

A sample piece of code that uses the AccountLinkingController controller can be seen here:

$controller = new AccountLinkingController($credentialStore);

$controller->onGetUserId(function ($req) {

 $id = $db->getId($req->getInfoField1(),$req->getInfoField2());
 $res = new GetUserIdResponse();

 if ($id) {
    $res->setResponse(GetUserIdResponseValue::OK);
    $res->setUserId($id);
 } else {
    $res->setResponse(GetUserIdResponseValue::FAIL_ACCOUNT_INVALID);
 }

 return $res;

});

$response = $controller->process($_SERVER);
echo $response;