21 November 2011
Posted in MyEmma
Here's a quick example of how easy it is to integrate Emma with a third-party application. In this example, we're going to take all the members from a group in Emma and create them as new contacts in Highrise.
Let's get our hands dirty and jump into the code straight away.
Example Code:
require_once('../../MyEmmaPHP.php');
require_once('HighriseAPI.class.php');
/*
** First, let's grab everyone from our signup list and cache the results
** We're going to use MyEmma Group 10596 as our source list
*/
try {
/*
** We've got our access credentials in our config file, so we don't need to
** pass them to the class constructor.
*/
$me = new MyEmmaPHP();
/*
** List all the members in group 10596, and store them in $me_members
*/
$me_members = $me->listGroupMembers(10596);
} catch ( Exception $e ) {
echo $e->getMessage() . "\n\n";
}
/*
** Now let's create an instance of the HighriseAPI class. It's available at:
** https://github.com/ignaciovazquez/Highrise-PHP-Api.github
*/
$highrise = new HighriseAPI();
$highrise->debug = false;
/*
** Your Highrise account is the first segment of your Highrise URL
** For example, our URL is synergycodeworksllc.highrisehq.com
*/
$highrise->setAccount('synergycodeworksllc');
/*
** Your API token can be found under your My Info screen in Highrise
*/
$highrise->setToken('your-token-is-under-My-Info-in-your-highrise-account');
foreach ($me_members as $member) {
$person = new HighrisePerson($highrise);
$person->setFirstName($member->fields->name_first);
$person->setLastName($member->fields->name_last);
$person->addEmailAddress($member->email);
$person->save();
print "A new person has been created in Highrise with an ID of : " . $person->getId() . "\n";
}
There are obviously a lot of other things you'd want to do in a full integration, but this serves as one example of how easy it is to use EmmaPHP to sync up a group in a third-party application.
Useful Links:
And of course, if you like the idea of an integration between Emma and Highrise - or any other API-enabled service - but don't feel like coding it up yourself, just Contact Us. We'd be happy to help.
People talking about '@synergycode':
Comments (0)