Create a new search definition in Emma.
Each search criterion is specified as an array with several values. The actual number of values depends on the filter type in question:
Figuring out your search criteria can be a bit tricky. In the example provided below, we've created a search that includes any member belonging to at least one of the groups listed, with an email preference (custom field) either not set (undefined), or set to 'Weekly' or 'Not Specified'. The example gives you one example of an array you need to pass to createSearch().
Another good way to get your hands dirty constructing criteria is to create representative samples of searches using the Emma web interface, and then using listSearches() and/or getSearchDetail() to see how they're structured in Emma. You can also refer to Emma's API documentation for create_search, just keep in mind that their internal representation of the criteria is a JSON array.
Arguments:
Use:
require_once('../../MyEmmaPHP.php');
try {
$me = new MyEmmaPHP();
$name = 'PeopleSoft Users with Weekly Emails Set';
$criteria =
array(
"and",
array(
"or",
array("group", "in", "General: Marketing Contacts Only - PeopleSoft"),
array("group", "in", "SIG: PeopleSoft Compensation & Benefits"),
array("group", "in", "Product: PeopleSoft"),
array("group", "in", "Interest: Absence Management")
),
array(
"or",
array("member_field:wildcard_1355694", "undefined"),
array("member_field:wildcard_1355694", "contains", "Weekly"),
array("member_field:wildcard_1355694", "contains", "Not Specified")
)
);
$retval = $me->createSearch($criteria, $name);
print_r($retval);
} catch ( Exception $e ) {
echo $e->getMessage() . "\n\n";
}
Wrapper for: create_search
Delete a single search in Emma.
Arguments:
Use:
require_once('../../MyEmmaPHP.php');
try {
$me = new MyEmmaPHP();
$search_id = 19200;
$retval = $me->deleteSearch($search_id);
if ($retval) {
echo "Search deleted successfully.\n";
} else {
echo "Search not deleted.\n";
}
} catch ( Exception $e ) {
echo $e->getMessage() . "\n\n";
}
Wrapper for: delete_search
Retrieve details for a single search in Emma.
Arguments:
Use:
require_once('../../MyEmmaPHP.php');
try {
$me = new MyEmmaPHP();
$retval = $me->getSearchDetail(16128);
print_r($retval);
} catch ( Exception $e ) {
echo $e->getMessage() . "\n\n";
}
Wrapper for: get_search_detail
Retrieve a list of members matching a defined search in Emma.
Arguments:
Use:
require_once('../../MyEmmaPHP.php');
try {
$me = new MyEmmaPHP();
$retval = $me->getSearchMembers(19200);
print_r($retval);
} catch ( Exception $e ) {
echo $e->getMessage() . "\n\n";
}
Wrapper for: get_search_members
Retrieve a list of all the searches in an account in Emma.
Arguments:
Use:
require_once('../../MyEmmaPHP.php');
try {
$me = new MyEmmaPHP();
$retval = $me->listSearches();
print_r($retval);
} catch ( Exception $e ) {
echo $e->getMessage() . "\n\n";
}
Wrapper for: list_searches
Update a search definition in Emma.
Arguments:
Both $criteria and $search_name are optional, but you need to supply at least one of them to update. If you do not wish to update the search criteria, pass null as the argument.
Use:
require_once('../../MyEmmaPHP.php');
try {
$me = new MyEmmaPHP();
$search_id = 19200;
$name = 'PeopleSoft Members with Weekly Email Pref';
$criteria =
array(
"and",
array(
"or",
array("group", "in", "General: Marketing Contacts Only - PeopleSoft"),
array("group", "in", "SIG: PeopleSoft Compensation & Benefits"),
array("group", "in", "Product: PeopleSoft"),
array("group", "in", "Interest: Absence Management")
),
array(
"or",
array("member_field:wildcard_1355694", "undefined"),
array("member_field:wildcard_1355694", "contains", "Weekly"),
array("member_field:wildcard_1355694", "contains", "Not Specified")
)
);
$retval = $me->updateSearch($search_id, $criteria, $name);
if ($retval) {
echo "Search updated successfully.\n";
} else {
echo "Search not updated.\n";
}
} catch ( Exception $e ) {
echo $e->getMessage() . "\n\n";
}
Wrapper for: update_search
People talking about '@synergycode':