Skip to content

Instantly share code, notes, and snippets.

@MasonM
Last active December 17, 2015 17:29
Show Gist options
  • Save MasonM/5646755 to your computer and use it in GitHub Desktop.
Save MasonM/5646755 to your computer and use it in GitHub Desktop.
This code creates a new account in Nutshell with an example address.
<?php
define('USERNAME', 'jim@demo.nutshell.com');
define('PASSWORD', '43c789d483fd76547b1f157e3cf5e580b95b9d8c');
function findEndpoints($username) {
$soapClient = new SoapClient("http://api.nutshell.com/v1/soap?wsdl");
return $soapClient->getApiForUsername($username);
}
$endpoints = findEndpoints(USERNAME);
$soapOptions = array(
'soap_version' => SOAP_1_2,
'user_agent' => 'Nutshell',
'login' => USERNAME,
'password' => PASSWORD,
'trace' => true,
);
$soapClient = new SoapClient("http://{$endpoints['api']}/api/v1/soap?wsdl", $soapOptions);
$result = $soapClient->newAccount(array(
'name' => 'this is a test',
'address' => array(
// One array for each address.
// This request just has one, but you can have an unlimited number of addresses on an account
array(
'address_1' => '100 Second St.',
'address_2' => 'Apt. 4',
'address_3' => 'c/o Barclay Fowler',
'city' => 'Ann Arbor',
'state' => 'MI',
'postalCode' => '48103',
'country' => 'US',
),
),
));
var_dump($result);
echo $soapClient->__getLastRequest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment