4/7/08 12:11 pm - post a contact from a form into highrisehq
Some php that will put the output of a contact form into highrisehq. Uses the simplehighrise.php wrapper from:
http://www.activistnerd.com/simplehighr ise-a-php-wrapper-class-for-the-highrise-a pi/
had to hack up a different get_ID solution, as neither of the ways the wrapper did it work for me. almost certainly related to php version (them 5 me 4)
also note that I put the contacts into a company called DEMOFORM, as I couldn't create and apply a tag. Let me know if you can
http://www.activistnerd.com/simplehighr
had to hack up a different get_ID solution, as neither of the ways the wrapper did it work for me. almost certainly related to php version (them 5 me 4)
also note that I put the contacts into a company called DEMOFORM, as I couldn't create and apply a tag. Let me know if you can
//info about person
$firstName = $name;
$lastName = "";
$phoneNumber = $phone;
$companyName = "DEMOFORM";
$emailAddress = $email;
$noteBody ="Feedback Submitted! \n Name:".$name."\n Organization: ".$org."\n Email:".$email."\n Phone: ".$phone."\n Subje
ct: ".$subject."\n Interests: ".$str."\n Message: ".$msg;
;
//set up for highrise--put your token below
include('simplehighrise.php');
$token = "blah4532jh5l2jkh348gshljhblahblah".":fo o"; // tack on : (colon) and dummy password
$hr = new SimpleHighrise('foobar', $token);
//function to pull first found persons ID out of the xml
function find_ID ($result = ""){
// goto person section
$PersonLine=strpos($result, "");
$string=substr($result, $PersonLine);
//goto ID line
$IDLine=strpos($result, "");
$string=substr($result, $IDLine);
// find first and last position of ID field
$IDLine=strpos($string,">");
$IDLineEnd=strpos($string," ");
//save out the ID
$string=substr($string,$IDLine + 1,$IDLineEnd - 1 - $IDLine );
return $string;
}
//search for person current ID
$searchResult = $hr->search_people($firstName);
$personId = find_ID($searchResult);
//if they don't exist, then create them
if ($personId == ""){
$createResult = $hr->create_new_person($firstName, $lastName, $phoneNumber, $companyName, $emailAddress);
$personId = find_ID($createResult);
}
// note rest of info onto person
$noteResult = $hr->create_new_note_person($personId, $body = $noteBody, $subjectType = "DEMOFORM");
//echo $result;
//end by going to a thank you page
header("Location: http://example.com/thanks.html");