Use of the PHP API?

  • I need to send in a request to register and login a user. My app uses CodeIgniter. I understand that my app needs to fill in this structure with my own data and then send it:
    "applicationId": "10000000-0000-0002-0000-000000000001",
    "loginId": "",
    "state": {
    "client_id": "10000000-0000-0002-0000-000000000001",
    "redirect_uri": "",
    "response_type": "code",
    "scope": "openid",
    "state": "CSRF123"
    Is there any example code? I have already initialized the $client. I am not sure how to create a json structure in PHP. I am also not sure how to submit it in PHP? Any examples I could copy?

  • Hiya,

    You might want to check out this blog post: which has some PHP client library examples.

  • Perfect. thx

  • I am trying to register and login my user via php API. Here is my $request:

    $request = array();
    $request["applicationId"] = $applicationId;
    $request["loginId"] = "";
    $request["password"] = "";
    $result =$_SESSION['client']->login($request);
    if (!$result->wasSuccessful()) {
    // Error

    $result is returning null and thus failing. Any idea where I would look to solve this? Is there a different function for register/login? Or do I have to manually register this user prior to logging him in? I am trying to find the list of API functions?

  • I think you want the applicationId to be part of a registration object.

    $registrations = [];
    $registration = [];
    $registration['applicationId'] = $appid;
    array_push($registrations, $registration);
    $user['registrations'] = $registrations;

  • I am confused by this response. I found the register() function in the php client documentation. It should be register($userid,$request);. For the $userid I am planning on using the email_address. For the $request I plan on using this:
    $applicationId = "32688330-1630-4e0d-a4de-8ae45c3ca527";
    $request = array();
    $request["applicationId"] = $applicationId;
    $request["loginId"] = $post_array[employee_email];
    $request["password"] = "";

    So it would be register($post_array[employee_email],$request);

    Is this the proper API call to register a user? This is returning a $result->errorResponse of null.

    What does this mean? Was the install bad?
    This line seems to have executed correctly (I think)
    $_SESSION['client'] = new FusionAuth\FusionAuthClient($apiKey, "http://localhost:9011");

Log in to reply