Created
April 1, 2010 14:33
-
-
Save davidcoallier/351863 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Services/Capsule.php'; | |
$appName = 'appName'; | |
$token = 'secretToken'; // Get that from the website | |
$oppId = 'superOpportunityId'; | |
// 1. Let's create a new person in our service | |
// 2. Fetch this user using party search | |
// 3. Update this user | |
// 4. Add him to an opportunity | |
// 5. Get a drink. | |
try { | |
$capsule = new Services_Capsule($appName, $token); | |
// #1: Let's create a new person in our service | |
$personInfo = array( | |
'contacts' => array( | |
'email' => array( | |
'type' => 'Work', | |
'emailAddress' => '[email protected]', | |
) | |
), | |
'title' => 'Mr', | |
'firstName' => 'David', | |
'lastName' => 'Gallchobair' | |
); | |
$personAdded = $capsule->person->add($personInfo); | |
if ($personAdded !== true) { | |
die('Oh noes could not create person'); | |
} | |
// #2: Fetch this user using party search | |
$search = $capsule->party->getAny(array( | |
'email' => '[email protected]' | |
)); | |
if (!isset($search->person->id)) { | |
die('Oh noes could not find the person'); | |
} | |
// #3: Update this user | |
$personUpdate = array('lastName' => 'Coallier'); | |
$personUpdated = $capsule->person->update( | |
$search->person->id, $personUpdate | |
); | |
if ($personUpdated !== true) { | |
//die('Oh noes could not update the person'); | |
} | |
// #4: Add him to an opportunity | |
$added = $capsule->opportunity->party->add( | |
$oppId, $search->person->id | |
); | |
// #5: Get a drink. | |
} catch (Services_Capsule_Exception $e) { | |
print_r($e); die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment