Difference between revisions of "REST API examples"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "1. Add user to aMember via API: <source> <? $url = 'http://YOURDOMAIN.COM/amember/api/users';. $fields = array( ... '_key' => 'SECRETKEY',. 'login' => '...")

Revision as of 04:43, 16 August 2012

1. Add user to aMember via API:

<?
$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);