prosenjit-itobuz
7/28/2014 - 10:51 PM

gistfile1.php

<?php

//put in your nation slug and token
$url ="https://<your slug>.nationbuilder.com/api/v1/people?access_token=<token>";

$data = array(
    'person' => array(
    'email' => "example@foo.com",
    'last_name' => "Bob",
    'first_name' => "Smith",
    'sex' => "M",
    'employer' => "Dexter Labs",
  ),
);

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, '10'); 
curl_setopt($ch, CURLOPT_HTTPHEADER, 

array("Content-Type: application/json","Accept: application/json"));

$json_data = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);

$json_response = curl_exec($ch);
curl_close($ch);

$response = json_decode($json_response, true);

print_r($response);

?>