$url = 'http://example.com/amember/api/users';
$fields = [
'_key' => 'SECRETKEY',
'login' => 'USERNAME',
'pass' => 'PASSWORD',
'email' => 'EMAIL',
'name_f' => 'FIRST NAME',
'name_l' => 'LAST NAME',
];
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-type: application/x-www-form-urlencoded"]);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Update user to aMember via API
//22 within below URL is ID of user that you want to update
$url = 'http://example.com/amember/api/users/22';
$fields = [
'_key' => 'SECRETKEY',
'name_f' => 'FIRST NAME',
'name_l' => 'LAST NAME',
];
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-type: application/x-www-form-urlencoded"]);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
$ch = curl_init();
$url ="http://www.example.com/amember/api/access";
$vars = [
'_key' => 'xxxxxxx',
'user_id' => 1,
'product_id' => 1,
'begin_date' => date('Y-m-d'), // Today'expire_date' => '2037-12-31'// Lifetime
];
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-type: application/x-www-form-urlencoded"]);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Change expiration date for existing access record
$ch = curl_init();
$url ="http://www.example.com/amember/api/access/5051"; // Access id should be included in url
$vars = [
'_key' => 'xxxxx',
'expire_date' => date('Y-m-d') // Set expire date to today's date
];
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); // Set method to PUT, so API module knows that this is update request.
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-type: application/x-www-form-urlencoded"]);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Retrieve list of access records for particular user