• Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login
FusionAuth
  • Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login

Use of the PHP API?

Scheduled Pinned Locked Moved
General Discussion
2
6
5.6k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    richb201
    last edited by richb201 24 Sept 2020, 20:12

    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": "jared@piedpiper.com",
    "state": {
    "client_id": "10000000-0000-0002-0000-000000000001",
    "redirect_uri": "https://piedpiper.com/callback",
    "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?

    1 Reply Last reply Reply Quote 0
    • D
      dan
      last edited by 24 Sept 2020, 20:24

      Hiya,

      You might want to check out this blog post: https://fusionauth.io/blog/2020/03/26/how-to-integrate-fusionauth-with-php which has some PHP client library examples.

      --
      FusionAuth - Auth for devs, built by devs.
      https://fusionauth.io

      1 Reply Last reply Reply Quote 0
      • R
        richb201
        last edited by 24 Sept 2020, 23:01

        Perfect. thx

        1 Reply Last reply Reply Quote 1
        • R
          richb201
          last edited by richb201 25 Sept 2020, 20:18

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

          $request = array();
          $request["applicationId"] = $applicationId;
          $request["loginId"] = "dave@yahoo.com";
          $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?

          1 Reply Last reply Reply Quote 0
          • D
            dan
            last edited by 25 Sept 2020, 22:53

            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;
            

            --
            FusionAuth - Auth for devs, built by devs.
            https://fusionauth.io

            1 Reply Last reply Reply Quote 0
            • R
              richb201
              last edited by richb201 26 Sept 2020, 23:51

              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.
              status=0
              successResponse=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");

              1 Reply Last reply Reply Quote 0
              4 out of 6
              • First post
                4/6
                Last post