Beispiel #1
0
 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;
 }
Beispiel #2
0
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 doPostToGooglePlus($connectID, $msg, $lnk = '', $pageID = '') {
		return doPostToGooglePlus2 ( $msg, $lnk, $pageID );
	}
 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 "&nbsp;&nbsp;&nbsp;&nbsp;### ".$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("&deg;","&#176;",$msg); $msg = str_ireplace("&uuml;","&#220;",$msg);
      $msg = str_ireplace("&szlig;","&#223;",$msg); $msg = str_ireplace("&nbsp;","&#160;",$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 "&nbsp;&nbsp;&nbsp;&nbsp;### 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; 
?>
Beispiel #6
0
 public function postToGplus($message, $params)
 {
     $email = Mage::getStoreConfig('besociable/gplus/email');
     $pass = Mage::getStoreConfig('besociable/gplus/password');
     $pageID = Mage::getStoreConfig('besociable/gplus/pageid');
     $postToProfile = Mage::getStoreConfigFlag('besociable/gplus/profile');
     $login = doConnectToGooglePlus2($email, $pass);
     if (!$login) {
         //$lnk = doGetGoogleUrlInfo2($params);
         $lnk = array('link' => $params['link'], 'fav' => '//s2.googleusercontent.com/s2/favicons?domain=' . $_SERVER['HTTP_HOST'], 'title' => $params['name'], 'domain' => $_SERVER['HTTP_HOST'], 'txt' => $params['description'], 'img' => $params['image'], 'imgType' => $params['image_type']);
         if ($postToProfile) {
             $result = doPostToGooglePlus2($message, $lnk, '');
         } else {
             $result = doPostToGooglePlus2($message, $lnk, $pageID);
         }
         if ($result == 'OK') {
             return true;
         } else {
             Mage::log('gplus response begin');
             Mage::log($result);
             Mage::log('gplus response end');
         }
         return false;
     }
     return false;
 }
if (!function_exists("doPostToGooglePlus")) {function doPostToGooglePlus($connectID, $msg, $lnk='', $pageID=''){ return doPostToGooglePlus2($msg, $lnk, $pageID);}}
 public function testgplusAction()
 {
     $message = 'Posted from ' . Mage::app()->getStore()->getFrontendName() . '---' . Mage::getModel('core/date')->timestamp(time());
     $email = Mage::getStoreConfig('besociable/gplus/email');
     $pass = Mage::getStoreConfig('besociable/gplus/password');
     $pageID = Mage::getStoreConfig('besociable/gplus/pageid');
     $login = doConnectToGooglePlus2($email, $pass);
     if (!$login) {
         //$lnk = doGetGoogleUrlInfo2($params);
         $picture = Mage::getDesign()->getSkinUrl(Mage::getStoreConfig('design/header/logo_src'), array('_area' => 'frontend'));
         $img = substr($picture, strlen($picture) - 3, strlen($picture));
         if ($img == 'jpg') {
             $imageType = 'image/jpeg';
         } else {
             if ($img == 'gif') {
                 $imageType = 'image/gif';
             } else {
                 if ($img == 'png') {
                     $imageType = 'image/png';
                 }
             }
         }
         $lnk = array('link' => $this->getFrontendUrl(''), 'fav' => '//s2.googleusercontent.com/s2/favicons?domain=' . $_SERVER['HTTP_HOST'], 'title' => $message, 'domain' => $_SERVER['HTTP_HOST'], 'txt' => $message, 'img' => Mage::getDesign()->getSkinUrl(Mage::getStoreConfig('design/header/logo_src'), array('_area' => 'frontend')), 'imgType' => $imageType);
         $result = doPostToGooglePlus2($message, $lnk, $pageID);
         if ($result == 'OK') {
             Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("sociable")->__('Test post has been posted to Google+. Please check your Goolge+ page.'));
         }
     } else {
         Mage::getSingleton("adminhtml/session")->addError(Mage::helper("sociable")->__('Could not login! Please check your Google+ Email and Password!'));
     }
     $this->_redirect("*/system_config/edit/section/besociable/");
 }