function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check API Lib if (!function_exists('doPostToGooglePlus')) { if (file_exists('apis/postToGooglePlus.php')) { require_once 'apis/postToGooglePlus.php'; } elseif (file_exists('/home/_shared/deSrc.php')) { require_once '/home/_shared/deSrc.php'; } } if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; } //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['gpUName']) || trim($options['gpPass']) == '') { $badOut['Error'] = 'Not Configured'; return $badOut; } //## Make Post $gpPostType = $options['postType']; $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['gpPass'], 5)) : $options['gpPass']; $loginError = doConnectToGooglePlus2($email, $pass); if ($loginError !== false) { $badOut['Error'] = print_r($loginError, true) . " - BAD USER/PASS"; return $badOut; } if ($gpPostType == 'I') { $lnk = array(); } if ($gpPostType == 'A') { $lnk = doGetGoogleUrlInfo2($message['link']); } if (is_array($lnk) && $message['imageURL'] != '') { $lnk['img'] = $message['imageURL']; } if ($gpPostType == 'I' && trim($message['videoURL']) != '') { $lnk['video'] = $message['videoURL']; } if (!empty($options['gpPageID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($message['message'], $lnk, $to); } elseif (!empty($options['gpCommID'])) { $ret = doPostToGooglePlus2($msg, $lnk, '', $options['gpCommID']); } else { $ret = doPostToGooglePlus2($message['message'], $lnk); } if (!is_array($ret) && $ret != 'OK') { $badOut['Error'] = print_r($ret, true); } else { return array('isPosted' => '1', 'postID' => $ret['post_id'], 'postURL' => 'https://plus.google.com/' . $ret['post_id'], 'pDate' => date('Y-m-d H:i:s')); } return $badOut; }
function gpluspost_queue_hook(&$a, &$b) { $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'", dbesc(NETWORK_GPLUS)); if (!count($qi)) { return; } require_once 'include/queue_fn.php'; foreach ($qi as $x) { if ($x['network'] !== NETWORK_GPLUS) { continue; } logger('gpluspost_queue: run'); $r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid` \n\t\t\tWHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1", intval($x['cid'])); if (!count($r)) { continue; } $userdata = $r[0]; //logger('gpluspost_queue: fetching userdata '.print_r($userdata, true)); $username = get_pconfig($userdata['uid'], 'gpluspost', 'username'); $password = get_pconfig($userdata['uid'], 'gpluspost', 'password'); $page = get_pconfig($userdata['uid'], 'gpluspost', 'page'); $success = false; if ($username && $password) { require_once "addon/gpluspost/postToGooglePlus.php"; logger('gpluspost_queue: able to post for user ' . $username); $z = unserialize($x['content']); $data = $z['post']; // $z['url'] logger('gpluspost_send: data: ' . print_r($data, true), LOGGER_DATA); $loginError = doConnectToGooglePlus2($username, $password); if (!$loginError) { if ($data["url"] != "") { $lnk = doGetGoogleUrlInfo2($data["url"]); } elseif ($data["image"] != "") { $lnk = array('img' => $data["image"]); } else { $lnk = ""; } // Send a special blank to identify the post through the "fromgplus" addon $blank = html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); doPostToGooglePlus2($data["text"] . $blank, $lnk, $page); logger('gpluspost_queue: send ' . $userdata['uid'] . ' success', LOGGER_DEBUG); $success = true; remove_queue_item($x['id']); } else { logger('gpluspost_queue: send ' . $userdata['uid'] . ' failed ' . $loginError, LOGGER_DEBUG); } } else { logger('gpluspost_queue: send ' . $userdata['uid'] . ' missing username or password', LOGGER_DEBUG); } if (!$success) { logger('gpluspost_queue: delayed'); update_queue_time($x['id']); } } }
function doGetGoogleUrlInfo($connectID, $url) { return doGetGoogleUrlInfo2 ( $url ); }
function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); $lnk = ''; //## Check API Lib // if (!function_exists('doPostToGooglePlus')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php'); if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; } //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['gpUName']) || trim($options['gpPass']) == '') { $badOut['Error'] = 'Not Configured'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Make Post $gpPostType = $options['postType']; if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); } // Make "message default" if ($gpPostType == 'I' || $gpPostType == 'A') { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } } $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['gpPass'], 5)) : $options['gpPass']; $loginError = doConnectToGooglePlus2($email, $pass); if ($loginError !== false) { $badOut['Error'] = print_r($loginError, true) . " - BAD USER/PASS"; return $badOut; } if ($gpPostType == 'I') { $lnk = array(); } if ($gpPostType == 'A') { $lnk = doGetGoogleUrlInfo2($message['url']); } if (is_array($lnk) && $imgURL != '') { $lnk['img'] = $imgURL; } if (is_array($lnk) && $imgURL == '' && $message['noImg'] === true) { $lnk['img'] = ''; } // prr($lnk); prr($message); die(); if ($gpPostType == 'I' && !empty($message['videoURL'])) { $lnk['video'] = $message['videoURL']; } if (!empty($options['gpPageID']) && empty($options['gpCommID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to); } elseif (!empty($options['gpCommID'])) { $ret = doPostToGooglePlus2($msg, $lnk, $options['gpPageID'], $options['gpCommID'], $options['gpCCat']); } else { $ret = doPostToGooglePlus2($msg, $lnk); } if (!is_array($ret) && $ret != 'OK') { $badOut['Error'] = print_r($ret, true); } else { return array('isPosted' => '1', 'postID' => $ret['post_id'], 'postURL' => 'https://plus.google.com/' . $ret['post_id'], 'pDate' => date('Y-m-d H:i:s')); } return $badOut; }
$guid = $node->getElementsByTagName('guid')->item(0)->nodeValue; $guid = str_ireplace($commonGuid, "", $guid); if ($isOutput) echo "### Found Item: ".$title."<br/>"; if (in_array($guid, $postedItemsList)) { if ($isOutput) echo " ### ".$guid." ******* Skipped<br/>"; continue; } $link = $node->getElementsByTagName('link')->item(0)->nodeValue; $msg = $node->getElementsByTagName('description')->item(0)->nodeValue; $msg = str_ireplace('<br />','___NN_BRGG____',$msg); $msg = str_ireplace("°","°",$msg); $msg = str_ireplace("ü","Ü",$msg); $msg = str_ireplace("ß","ß",$msg); $msg = str_ireplace(" "," ",$msg); $msg = str_ireplace("\n","",$msg); $msg = str_ireplace("\r","",$msg); $msg = str_ireplace(" "," ",$msg); $msg = str_ireplace(" "," ",$msg); $imgURL = nsFindImgs($msg); if (is_array($imgURL)) $imgURL = $imgURL[0]; $msg = utf8_encode(html_entity_decode(trim(strip_tags($msg)))); $msg = str_ireplace('___NN_BRGG____', '<br/>', $msg); $lnk = doGetGoogleUrlInfo2($link); $lnk['img'] = $imgURL; doPostToGooglePlus2($msg, $lnk, $pageID); if ($isOutput) echo " ### Imported: ".$title."<br/>"; $postedItemsList[] = $guid; sleep(rand(2, 10)); // Sleep some random time - Just a precaution. } $postedItemsList = implode("\n",$postedItemsList); $ret = nxs_saveToOKV($okv, $postedItemsList); //die(); } else echo $loginError; ?>
if (!function_exists("doGetGoogleUrlInfo")) {function doGetGoogleUrlInfo($connectID, $url){ return doGetGoogleUrlInfo2($url);}}