Emma PHP: createSearch()

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:

  • Filter type - and, or, not, group, opened, clicked
  • Operator
  • Value

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: 

  • array $criteria - The criteria that define the search.
  • string $search_name - The name for your new search.

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

Keep in Touch

Contact Us

Buzz

Loading...

People talking about '@synergycode':