REST API examples

From aMember Pro Documentation
Revision as of 04:48, 16 August 2012 by Alexander (Talk | contribs)

Jump to: navigation, search
  • Add user to aMember via API:
<?php
$url = 'http://YOURDOMAIN.COM/amember/api/users';.
 
$fields = array(
            '_key' => 'SECRETKEY',.
            'login' => 'USERNAME',.
            'pass' => 'PASSWORD',.
            'email' => 'EMAIL',.
            'name_f' => 'FIRST NAME',.
            'name_l' => 'LAST NAME',.
            'format' => 'XML',.
    );
 
 
$fields_string  = http_build_query($fields);
//open connection
$ch = curl_init();
 
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
 
//execute post
$result = curl_exec($ch);
 
//close connection
curl_close($ch);