Create a contact and add them to a group

// get the node for the group
$group = $GLOBALS["WT"]->getNode("/Groups/Group Name");

if ($group) {
  // set the attributes for the contact
  $attributes = Array();
  $attributes["First Name"] = "John";
  $attributes["Last Name"] = "Smith";
  $attributes["Email Address"] = "john.smith@domainname.com";

  // set the contact group for the contact
  $attributes["Contact Groups"] = $group->m_guid;

  // create the contact
  $contacts = $GLOBALS["WT"]->getNode("/Contacts");
  $contact = $contacts->createChild("Contact", $attributes);
}