Create user using the api

Discussion in 'Integration' started by mjthorpe, Jun 22, 2015.

  1. mjthorpe

    mjthorpe New Member

    Jun 22, 2015
    Although Im no stranger to coding Im pretty new to php and Im starting to feel like a bit of a numpty here, all im trying to do is to use the sample php code to create a test user on my new installation. Im using the example php code :

    $url = '';

    $fields = array(
    '_key' => 'xxx',
    '_format' => 'xml',
    'login' => 'USERNAME',
    'pass' => 'PASSWORD',
    'email' => 'EMAIL',
    'name_f' => 'FIRSTNAME',
    'name_l' => 'LASTNAME',
    //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, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));

    //execute post
    $result = curl_exec($ch);

    //close connection

    I have created a remote API permission in aMember with full user permissions and entered the key into the code above, then created a php file and copied it to my web server. When I call it in a browser however nothing happens, no error, no messages just a blank page. No user is created when I check in aMember and no errors are logged (I have turned on Rest error logging). Can anybody shed any light into what Im doing wrong.


Share This Page