1 Reply Latest reply on Dec 21, 2015 6:27 AM by gregorytdunn91

    REST API v3 and PHP cURL

    gregorytdunn91

      So I wrote a basic PHP cURL to create a user, but I'm getting an empty response from the Jive Rest API.  See the script below (Note sensitive information has been *****-ed out). Anyone have suggestions for troubleshooting? I have no php errors or warning in the logs. This same call works fine from the command line or the Advanced Rest Chrome extension.

       

      <?php

      // variables

      $url = "https://**********.com/api/core/v3/people/?welcome=true";

      $email = "*****@*****.com";

      $username = "*****";

      $password = "*****";

      $lastName ="Test";

      $firstName ="Greg";               

       

      // data

      $data = array("emails" => array("value" => $email, "jive_label" => "Email"), "jive" => array("password" => $password, "username" => $username), "name" => array("familyName" => $lastName, "givenName" => $firstName));

      $data_string = json_encode($data);

       

      // headers

      $headers = array('Content-Type: application/json');

       

      // POST JSON data using Jive Rest API

      $ch = curl_init();

      curl_setopt($ch, CURLOPT_URL, $url);

      curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

      curl_setopt($ch, CURLOPT_USERPWD, '*****:*****');

      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                               

      $result = curl_exec($ch);

      curl_close($ch);

       

      // Print Result Info

      echo "<br>Response:<br>".(string)$result;

      ?>