Created
June 3, 2016 11:29
-
-
Save philicious/680e785a8f32cb7cb3a52b668f01dfd8 to your computer and use it in GitHub Desktop.
Dreamfactory user creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$user = [ | |
'name' => $postData['email'], | |
'email' => $postData['email'], | |
'first_name' => $postData['firstname'], | |
'last_name' => $postData['lastname'], | |
'password' => $postData['password'] | |
]; | |
$data = [ | |
'resource' => [$user] | |
]; | |
// now create the API user | |
$ch = curl_init("{$apiBaseUrl}/api/v2/system/user?session_token={$token['session_token']}"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
$resource = json_decode($response, true); | |
$userId = $resource['resource'][0]['id']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment