- Description
This end-points gives access to the Users section. - Available methods
GET, POST, PUT, DELETE
GET
Get all users available.
Required headers
- X-API-KEY
- Authorization
Payload
Not applicable
Return
Returns a JSON string containing a list of the users currently available.
Example (php)
The example below retrieves a JSON string ($result) containing all the users currently in the application:
$curl = curl_init();
// Make sure you insert the correct URL below; this should point to your copy of Bloxby
$url = "http://getpageless.com/api/users/";
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions)
curl_setopt($curl, CURLOPT_USERPWD, "user:password");
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
echo $result;
POST
Creates a new user.
Required headers
- X-API-KEY
- Authorization
Payload
A POST request should have a form-data encoded payload, containing name-value pairs corresponding to attributes of the new user. The following are allowed:
- first_name [required, string]: first name of the new user
- last_name [required, string]: last name of the new user
- email [required, string]: email address of the new user
- password [required, string]: password for the new user
- type [required, string]: user type for the new user (should be either “User” or “Admin”)
- package_id [required, number]: package ID for the package the new user should be subscribed to
Return
On success, the end-point will contain a JSON string representing the created user.
Example (php)
The following example creates a new user:
$curl = curl_init();
// Make sure you insert the correct URL below; this should point to your copy of Bloxby
$url = "http://getpageless.com/api/users/";
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions)
curl_setopt($curl, CURLOPT_USERPWD, "user:password");
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = array();
$data['first_name'] = "John";
$data['last_name'] = "Doe";
$data['email'] = "[email protected]";
$data['password'] = "MySecretPassword";
$data['first_name'] = "John";
$data['package_id'] = 1;
$data['type'] = "User";
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($curl);
curl_close($curl);
echo $result;
PUT
Updates an existing user.
Required headers
- X-API-KEY
- Authorization
Payload
A PUT request should append a valid user ID to the end-point url, as such: “/api/users/12”.
A PUT request should have a x-www-form-urlencoded encoded payload, containing name-value pairs corresponding to attributes of the new package. The following are allowed:
- first_name [optional, string]: first name of the new user
- last_name [optional, string]: last name of the new user
- email [optional, string]: email address of the new user
- password [optional, string]: password for the new user
- type [optional, string]: user type for the new user (should be either “User” or “Admin”)
- status [optional, string]: indicates if the user account is enabled or disabled (should be either “Active” or “Inactive”)
Return
On success, the end-point will contain a JSON string representing the updated user.
Example (php)
The following example edits the user with ID = 2:
$curl = curl_init();
// Make sure you insert the correct URL below; this should point to your copy of Bloxby and included the ID for the user you'd like to edit
$url = "http://getpageless.com/api/users/2";
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions) c
url_setopt($curl, CURLOPT_USERPWD, "user:password");
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
$data = array();
$data['first_name'] = "Johnn";
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($curl);
curl_close($curl);
echo $result;
DELETE
Deletes a single user from the application.
Required headers
- X-API-KEY
- Authorization
Payload
A DELETE request should append a valid user ID to the end-point url, as such: “/api/users/12”.
Return
On success, the API will return a message confirming deletion of the user.
Example (php)
The following example deletes user with ID = 2:
$curl = curl_init();
// Make sure you insert the correct URL below; this should point to your copy of Bloxby and included the ID for the user you'd like to delete
$url = "http://getpageless.com/api/users/2";
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions)
curl_setopt($curl, CURLOPT_USERPWD, "user:password");
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
$result = curl_exec($curl);
curl_close($curl);
echo $result;
Leave A Comment?
You must be logged in to post a comment.