Skip to content

Instantly share code, notes, and snippets.

@ArionHardison
Created July 28, 2014 22:51
Show Gist options
  • Save ArionHardison/4828c259dc0f8d4ab2af to your computer and use it in GitHub Desktop.
Save ArionHardison/4828c259dc0f8d4ab2af to your computer and use it in GitHub Desktop.
<?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' => "[email protected]",
'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);
?>
@wgbartley
Copy link

You might need to add curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); to your cURL options for this example to work in some environments.

Thanks for the example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment