- 29 May 2009, 16:00
#772
Here we go Russ - I promised a while back... a quick hack that will get your CATS Twittering... Enjoy!
Add this function to the top of your cats/lib/JobOrders.php --- right after include libraries:
function postToTwitter($username,$password,$message)
{
$host = "http://twitter.com/statuses/update.xml? ... .urlencode(stripslashes(urldecode($message)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);
curl_close($ch);
if($resultArray['http_code'] == "200"){
$twitter_status='Your message has been sent! <a href="http://twitter.com/'.$username.'">See your profile</a>';
} else {
$twitter_status="Error posting to Twitter. Retry";
}
return $twitter_status;
}
.........
after add this to the bottom of public function add($title, $companyID, $contactID, $description, $notes,:
postToTwitter("YOUR_USER_NAME","YOUR_PASSWORD",str_replace("'","",$this->_db->makeQueryString($title)." Job in ".$this->_db->makeQueryString($city).", ".$this->_db->makeQueryString($state)." http://www.YOURSITE_WITH_CATS_ONIT.com/YOURURL_AND_JOBORDER?id=".$jobOrderID));
..... right before return $joborderid;
ENJOY!!!!!!!!!!!!
Add this function to the top of your cats/lib/JobOrders.php --- right after include libraries:
function postToTwitter($username,$password,$message)
{
$host = "http://twitter.com/statuses/update.xml? ... .urlencode(stripslashes(urldecode($message)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);
curl_close($ch);
if($resultArray['http_code'] == "200"){
$twitter_status='Your message has been sent! <a href="http://twitter.com/'.$username.'">See your profile</a>';
} else {
$twitter_status="Error posting to Twitter. Retry";
}
return $twitter_status;
}
.........
after add this to the bottom of public function add($title, $companyID, $contactID, $description, $notes,:
postToTwitter("YOUR_USER_NAME","YOUR_PASSWORD",str_replace("'","",$this->_db->makeQueryString($title)." Job in ".$this->_db->makeQueryString($city).", ".$this->_db->makeQueryString($state)." http://www.YOURSITE_WITH_CATS_ONIT.com/YOURURL_AND_JOBORDER?id=".$jobOrderID));
..... right before return $joborderid;
ENJOY!!!!!!!!!!!!