function nxs_doPublishToYT($postID, $options)
 {
     $ntCd = 'YT';
     $ntCdL = 'yt';
     $ntNm = 'YouTube';
     $post = '';
     global $nxs_gCookiesArr;
     $vUrl = '';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     // $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToYT',  array($postID, $options));
     $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName']));
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     if (empty($options['ytGPPageID'])) {
         $options['ytGPPageID'] = '';
     }
     // if (empty($options['imgSize'])) $options['imgSize'] = '';
     if (!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) {
         nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', '');
         return "No G+ API Lib Detected";
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#800000">YouTube</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             sleep(5);
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $uqID);
             return;
         }
     }
     if ($postID == '0') {
         $options['ytMsgFormat'] = 'Test Post, Please Ignore';
     } else {
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $options['ytMsgFormat'] = nsFormatMessage($options['ytMsgFormat'], $postID, $addParams);
         // prr($msg); echo $postID;
     }
     $extInfo = ' | PostID: ' . $postID . " - " . (is_object($post) ? $post->post_title : '');
     //## Message & Format
     $vids = nsFindVidsInPost($post);
     if (count($vids) > 0) {
         $vUrl = $vids[0];
     }
     $message = array('siteName' => $blogTitle, 'videoURL' => $vUrl);
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_YT();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Process Results
     if (!is_array($ret) || $ret['isPosted'] != '1') {
         //## Error
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         // ## All Good - log it.
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your ' . $logNT . ' Page. ', 'nxs_snap');
         } else {
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'pgID' => $ret['postID'], 'pDate' => date('Y-m-d H:i:s')));
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
Example #2
0
 function nxs_doPublishToPN($postID, $options)
 {
     global $nxs_gCookiesArr;
     $ntCd = 'PN';
     $ntCdL = 'pn';
     $ntNm = 'Pinterest';
     // $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPN',  array($postID, $options));
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#FA5069">Pinterest</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     $isAttachVid = $options['isAttachVid'];
     $isAttachVid = '1';
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             sleep(5);
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $uqID);
             return;
         }
     }
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $msg = 'Test Post from ' . $blogTitle;
         $link = home_url();
         if ($options['pnDefImg'] != '') {
             $imgURL = $options['pnDefImg'];
         } else {
             $imgURL = "http://direct.gtln.us/img/nxs/NextScriptsLogoT.png";
         }
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $pnMsgFormat = $options['pnMsgFormat'];
         $msg = nsFormatMessage($pnMsgFormat, $postID);
         $link = get_permalink($postID);
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $imgURL = nxs_getPostImage($postID, 'large', $options['pnDefImg']);
         //prr($options); echo $imgURL."######"; // echo "WW".$postID."|";
         if ($isAttachVid == '1') {
             $vids = nsFindVidsInPost($post);
             if (count($vids) > 0) {
                 $vidURL = 'http://www.youtube.com/v/' . $vids[0];
                 $imgURL = 'http://img.youtube.com/vi/' . $vids[0] . '/0.jpg';
             }
         }
     }
     $email = $options['pnUName'];
     $boardID = $options['pnBoard'];
     $pass = substr($options['pnPass'], 0, 5) == 'g9c1a' ? nsx_doDecode(substr($options['pnPass'], 5)) : $options['pnPass'];
     // prr($boardID); prr($_POST); die();
     if (isset($options['pnSvC'])) {
         $nxs_gCookiesArr = maybe_unserialize($options['pnSvC']);
     }
     $loginError = true;
     if (is_array($nxs_gCookiesArr)) {
         $loginError = doCheckPinterest();
     }
     $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title;
     if ($loginError !== false) {
         $loginError = doConnectToPinterest($email, $pass);
     }
     if ($loginError !== false) {
         echo $loginError;
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($loginError, true), $extInfo);
         return "BAD USER/PASS";
     }
     if (serialize($nxs_gCookiesArr) != $options['pnSvC']) {
         global $plgn_NS_SNAutoPoster;
         $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
         // prr($gOptions['pn']);
         if (isset($options['ii']) && $options['ii'] !== '') {
             $gOptions['pn'][$options['ii']]['pnSvC'] = serialize($nxs_gCookiesArr);
             update_option('NS_SNAutoPoster', $gOptions);
         } else {
             foreach ($gOptions['pn'] as $ii => $gpn) {
                 $result = array_diff($options, $gpn);
                 if (!is_array($result) || count($result) < 1) {
                     $gOptions['pn'][$ii]['pnSvC'] = serialize($nxs_gCookiesArr);
                     update_option('NS_SNAutoPoster', $gOptions);
                     break;
                 }
             }
         }
     }
     // echo "PN SET:".$msg."|".$imgURL."|".$link."|".$boardID;
     if (preg_match('/\\$(\\d+\\.\\d+)/', $msg, $matches)) {
         $price = $matches[0];
     }
     $ret = doPostToPinterest($msg, $imgURL, $link, $boardID, 'TITLE WHERE IS IT?', $price, $link . "/GTH/");
     if ($ret == 'OK') {
         $ret = array("code" => "OK", "post_id" => '');
     }
     if (!is_array($ret) && $ret != 'OK') {
         if ($postID == '0') {
             echo $ret;
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo 'OK - Message Posted, please see your Pinterest Page';
         } else {
             nxs_metaMarkAsPosted($postID, 'PN', $options['ii'], array('isPosted' => '1', 'pgID' => $ret['post_id'], 'pDate' => date('Y-m-d H:i:s')));
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     if ($ret['code'] == 'OK') {
         return 200;
     } else {
         return $ret;
     }
 }
Example #3
0
 function nxs_doPublishToVK($postID, $options)
 {
     global $ShownAds, $nxs_vkCkArray;
     $ntCd = 'VK';
     $ntCdL = 'vk';
     $ntNm = 'vKontakte(VK)';
     $vidURL = '';
     $imgVURL = '';
     $dsc = '';
     $lng = '';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVK',  array($postID, $options));
     $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName']));
     if (empty($options['imgToUse'])) {
         $options['imgToUse'] = '';
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#000080">vKontakte</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $options['pType']);
             return;
         }
     }
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $urlToGo = home_url();
         $msg = 'Test Link from ' . $urlToGo;
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $options['msgFrmt'] = nxs_decodeEntitiesFull(strip_tags(nsFormatMessage($options['msgFrmt'], $postID, $addParams)));
         //## MyURL - URLToGo code
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
     }
     $extInfo = ' | PostID: ' . $postID . " - " . (is_object($post) ? $post->post_title : '') . ' |' . $options['pType'];
     //## Message & Format
     if (trim($options['imgToUse']) != '') {
         $imgURL = $options['imgToUse'];
     } else {
         $imgURL = nxs_getPostImage($postID, 'full');
     }
     if (preg_match("/noImg.\\.png/i", $imgURL)) {
         $imgURL = '';
     }
     if (function_exists('nxs_doPostToVK')) {
         $vids = nsFindVidsInPost($post);
         if (count($vids) > 0) {
             if (strlen($vids[0]) == 11) {
                 $vidURL = 'http://www.youtube.com/watch?v=' . $vids[0];
                 $imgURL = 'http://img.youtube.com/vi/' . $vids[0] . '/maxresdefault.jpg';
             }
             if (strlen($vids[0]) == 8) {
                 $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id=' . $vids[0] . '&autoplay=1';
                 //$mssg['source'] = 'http://player.vimeo.com/video/'.$vids[0];
                 $apiURL = "http://vimeo.com/api/v2/video/" . $vids[0] . ".json?callback=showThumb";
                 $json = wp_remote_get($apiURL);
                 if (!is_wp_error($json)) {
                     $json = $json['body'];
                     $json = str_replace('showThumb(', '', $json);
                     $json = str_replace('])', ']', $json);
                     $json = json_decode($json, true);
                     $imgVURL = $json[0]['thumbnail_large'];
                 }
             }
         }
     }
     if (!empty($options['attchAsVid']) && $options['attchAsVid'] == '1' && trim($imgVURL) != '') {
         $imgURL = $imgVURL;
     }
     if ($options['postType'] == 'A') {
         if (trim($options['msgAFormat']) != '') {
             $dsc = nsFormatMessage($options['msgAFormat'], $postID, $addParams);
         } else {
             if (function_exists('aioseop_mrt_fix_meta') && $dsc == '') {
                 $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
             }
             if (function_exists('wpseo_admin_init') && $dsc == '') {
                 $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
             }
             if (function_exists('wpseo_admin_init') && $dsc == '') {
                 $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
             }
             if (is_object($post) && $dsc == '') {
                 $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)));
             }
             if ($dsc == '') {
                 $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
             }
             if (is_object($post) && $dsc == '') {
                 $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)));
             }
             if ($dsc == '') {
                 $dsc = trim(nxs_doQTrans($post->post_content, $lng));
             }
             if (is_object($post) && $dsc == '') {
                 $dsc = get_bloginfo('description');
             }
         }
         $dsc = strip_tags($dsc);
         $dsc = nxs_decodeEntitiesFull($dsc);
         $dsc = nsTrnc($dsc, 900, ' ');
     } else {
         $dsc = '';
     }
     $message = array('siteName' => $blogTitle, 'url' => $urlToGo, 'imageURL' => $imgURL, 'videoURL' => $vidURL, 'urlTitle' => nxs_decodeEntitiesFull(nxs_doQTrans($post->post_title, $lng)), 'urlDescr' => $dsc);
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_VK();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Check Phone Req Return
     if (is_string($ret) && stripos($ret, 'Phone verification required:') !== false) {
         global $plgn_NS_SNAutoPoster;
         $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
         $phtext = str_ireplace('Phone verification required: ', '', $ret);
         $ret .= ". Please refresh/reload the SNAP settings page and enter your phone.";
         $gOptions['vk'][$ii]['vkPhReq'] = $phtext;
         update_option('NS_SNAutoPoster', $gOptions);
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true) . " - BAD USER/PASS", $extInfo);
         return " -= BAD USER/PASS - Phone verification required =- ";
     }
     //## Save Session
     if (empty($options['vkSvC']) || serialize($nxs_vkCkArray) != $options['vkSvC']) {
         global $plgn_NS_SNAutoPoster;
         $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
         if (isset($options['ii']) && $options['ii'] !== '') {
             $gOptions['vk'][$options['ii']]['vkSvC'] = serialize($nxs_vkCkArray);
             update_option('NS_SNAutoPoster', $gOptions);
         } else {
             foreach ($gOptions['vk'] as $ii => $gpn) {
                 $result = array_diff($options, $gpn);
                 if (!is_array($result) || count($result) < 1) {
                     $gOptions['vk'][$ii]['vkSvC'] = serialize($nxs_vkCkArray);
                     update_option('NS_SNAutoPoster', $gOptions);
                     break;
                 }
             }
         }
     }
     //## Process Results
     if (is_array($ret) && !empty($ret['err'])) {
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     }
     if (!is_array($ret) || $ret['isPosted'] != '1') {
         //## Error
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         // ## All Good - log it.
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your ' . $logNT . ' Page. ', 'nxs_snap');
         } else {
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'pgID' => $ret['postID'], 'pDate' => date('Y-m-d H:i:s')));
             $extInfo .= ' | <a href="' . $ret['postURL'] . '" target="_blank">Post Link</a>';
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
Example #4
0
 function nxs_doPublishToPN($postID, $options)
 {
     global $nxs_gCookiesArr, $plgn_NS_SNAutoPoster;
     $ntCd = 'PN';
     $ntCdL = 'pn';
     $ntNm = 'Pinterest';
     $price = '';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     // $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToPN',  array($postID, $options));
     $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName']));
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     if (empty($options['imgToUse'])) {
         $options['imgToUse'] = '';
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     if (empty($options['cImgURL'])) {
         $options['cImgURL'] = 'R';
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#FA5069">Pinterest</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     $isAttachVid = $options['isAttachVid'];
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             sleep(5);
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate |' . $uqID);
             return;
         }
     }
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $options['pnMsgFormat'] = 'Test Post from ' . $blogTitle;
         $urlToGo = home_url();
         if ($options['pnDefImg'] != '') {
             $imgURL = $options['pnDefImg'];
         } else {
             $imgURL = "http://direct.gtln.us/img/nxs/NXS-Lama.jpg";
         }
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $options['pnMsgFormat'] = nsFormatMessage($options['pnMsgFormat'], $postID, $addParams);
         //## MyURL - URLToGo code
         if (!isset($options['urlToUse']) || trim($options['urlToUse']) == '') {
             $myurl = trim(get_post_meta($postID, 'snap_MYURL', true));
         }
         if ($myurl != '') {
             $options['urlToUse'] = $myurl;
         }
         if (isset($options['urlToUse']) && trim($options['urlToUse']) != '') {
             $urlToGo = $options['urlToUse'];
             $options['useFBGURLInfo'] = true;
         } else {
             $urlToGo = get_permalink($postID);
         }
         if ($addParams != '') {
             $urlToGo .= (strpos($urlToGo, '?') !== false ? '&' : '?') . $addParams;
         }
         if (is_object($post)) {
             $urlToGo = apply_filters('nxs_adjust_ex_url', $urlToGo, $post->post_content);
         }
         if (!empty($options['imgToUse'])) {
             $imgURL = $options['imgToUse'];
         } else {
             $imgURL = nxs_getPostImage($postID, 'full', $options['pnDefImg']);
         }
         if (preg_match("/noImg.\\.png/i", $imgURL)) {
             $imgURL = '';
         }
         if ($isAttachVid == '1') {
             $vids = nsFindVidsInPost($post);
             if (count($vids) > 0) {
                 $vidURL = 'http://www.youtube.com/v/' . $vids[0];
                 $imgURL = 'http://img.youtube.com/vi/' . $vids[0] . '/0.jpg';
             }
         }
         $extInfo = ' | PostID: ' . $postID . " - " . is_object($post) ? $post->post_title : '';
     }
     if ($options['cImgURL'] == 'S') {
         $options['cImgURL'] = 'R';
     }
     //## Pinterest no longer allows shorthened URLs.
     //## Post
     $message = array('siteName' => $blogTitle, 'tags' => '', 'url' => $urlToGo, 'imageURL' => $imgURL);
     // prr($message);
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_PN();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Save Session
     if (serialize($nxs_gCookiesArr) != $options['ck']) {
         global $plgn_NS_SNAutoPoster;
         $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
         // prr($gOptions['pn']);
         if (isset($options['ii']) && $options['ii'] !== '') {
             $gOptions['pn'][$options['ii']]['ck'] = serialize($nxs_gCookiesArr);
             update_option('NS_SNAutoPoster', $gOptions);
         } else {
             foreach ($gOptions['pn'] as $ii => $gpn) {
                 $result = array_diff($options, $gpn);
                 if (!is_array($result) || count($result) < 1) {
                     $gOptions['pn'][$ii]['ck'] = serialize($nxs_gCookiesArr);
                     update_option('NS_SNAutoPoster', $gOptions);
                     break;
                 }
             }
         }
     }
     //## Process Results
     if (!is_array($ret) || $ret['isPosted'] != '1') {
         //## Error
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         // ## All Good - log it.
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your ' . $logNT . ' Page. ', 'nxs_snap');
         } else {
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'pgID' => $ret['postID'], 'postURL' => $ret['postURL'], 'pDate' => date('Y-m-d H:i:s')));
             $extInfo .= ' | <a href="' . $ret['postURL'] . '" target="_blank">Post Link</a>';
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     //prr($ret);
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
Example #5
0
 function nxs_doPublishToTR($postID, $options)
 {
     $ntCd = 'TR';
     $ntCdL = 'tr';
     $ntNm = 'Tumblr';
     global $plgn_NS_SNAutoPoster;
     $ytUrl = '';
     $imgURL = '';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTR',  array($postID, $options));
     if (empty($options['imgToUse'])) {
         $options['imgToUse'] = '';
     }
     if (empty($options['urlToUse'])) {
         $options['urlToUse'] = '';
     }
     if (empty($options['trMsgTFormat'])) {
         $options['trMsgTFormat'] = '';
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName']));
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#014A76">Tumblr</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $options['pType']);
             return;
         }
     }
     //## Format
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $options['trMsgFormat'] = 'Test Post from ' . $blogTitle;
         $msgT = 'Test Post from ' . $blogTitle;
         $options['trPostType'] = 'T';
         $postDate = gmdate("Y-m-d H:i:s") . " GMT";
         $tags = '';
         $urlToGo = '';
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $options['trMsgFormat'] = nsFormatMessage($options['trMsgFormat'], $postID, $addParams);
         $options['trMsgTFormat'] = nsFormatMessage($options['trMsgTFormat'], $postID, $addParams);
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $tggs = array();
         if ($options['trInclTags'] == '1') {
             $t = wp_get_post_tags($postID);
             $tggs = array();
             foreach ($t as $tagA) {
                 $tggs[] = $tagA->name;
             }
             $tags = implode(',', $tggs);
         }
         if ($options['trInclCats'] == '1') {
             $t = wp_get_post_categories($postID);
             foreach ($t as $c) {
                 $cat = get_category($c);
                 $tggs[] = $cat->name;
             }
             $tags = implode(',', $tggs);
         }
         $postDate = ($options['useOrDate'] == '1' && $post->post_date_gmt != '0000-00-00 00:00:00' ? $post->post_date_gmt : gmdate("Y-m-d H:i:s", strtotime($post->post_date))) . " GMT";
         //## Adds date to Tumblr post. Thanks to Kenneth Lecky
         if ($options['trPostType'] == 'V') {
             $vids = nsFindVidsInPost($post);
             if (count($vids) > 0) {
                 $ytUrl = $vids[0];
             }
             if (trim($ytUrl) == '') {
                 $options['trPostType'] = 'T';
             }
         }
         if ($options['trPostType'] == 'U') {
             $aud = nsFindAudioInPost($post);
             if (count($aud) > 0) {
                 $aUrl = $aud[0];
             }
             if (trim($aUrl) == '') {
                 $options['trPostType'] = 'T';
             }
         }
         if ($options['trPostType'] == 'I') {
             if (trim($options['imgToUse']) != '') {
                 $imgURL = $options['imgToUse'];
             } else {
                 $imgURL = nxs_getPostImage($postID, 'large', $options['trDefImg']);
             }
             if (preg_match("/noImg.\\.png/i", $imgURL)) {
                 $imgURL = '';
             }
             if (trim($imgURL) == '') {
                 $options['trPostType'] = 'T';
             }
         }
         //## MyURL - URLToGo code
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
     }
     $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? $post->post_title : '') . ' |' . $options['pType'];
     //## Post
     $message = array('siteName' => $blogTitle, 'imageURL' => $imgURL, 'tags' => $tags, 'url' => $urlToGo, 'postDate' => $postDate, 'videoURL' => $ytUrl);
     // prr($message); prr($options); die();
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_TR();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Process Results
     if (!is_array($ret) || $ret['isPosted'] != '1') {
         //## Error
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         // ## All Good - log it.
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your ' . $logNT . ' Page. ', 'nxs_snap');
         } else {
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'pgID' => $ret['postID'], 'postURL' => $ret['postURL'], 'pDate' => date('Y-m-d H:i:s')));
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     //prr($ret);
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
Example #6
0
 function nxs_doPublishToGP($postID, $options)
 {
     $ntCd = 'GP';
     $ntCdL = 'gp';
     $ntNm = 'Google+';
     if (!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) {
         nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', '');
         return "No G+ API Lib Detected";
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#800000">Google+</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $uqID);
             return;
         }
     }
     $message = array('message' => '', 'link' => '', 'imageURL' => '', 'videoURL' => '');
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $message['description'] = 'Test Post, Description';
         $message['title'] = 'Test Post - Title';
         $message['link'] = home_url();
     } else {
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $gpMsgFormat = $options['gpMsgFormat'];
         $gpPostType = $options['postType'];
         $msg = nsFormatMessage($gpMsgFormat, $postID);
         // prr($msg); echo $postID;
         $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title;
         if ($gpPostType == 'I') {
             $vids = nsFindVidsInPost($post, false);
             if (count($vids) > 0) {
                 $ytCode = $vids[0];
             }
             if (trim($ytCode) == '') {
                 $options['trPostType'] = 'T';
             }
         }
         if ($gpPostType == 'A') {
             $imgURL = nxs_getPostImage($postID, 'medium');
         }
         if ($gpPostType == 'I') {
             $imgURL = nxs_getPostImage($postID, 'full');
         }
         $message = array('message' => $msg, 'link' => get_permalink($postID), 'imageURL' => $imgURL, 'videoCode' => $ytCode);
     }
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_GB();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Process Results
     if (!is_array($ret) || $ret['isPosted'] != '1') {
         //## Error
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         // ## All Good - log it.
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your ' . $logNT . ' Page. ', 'nxs_snap');
         } else {
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'pgID' => $ret['postID'], 'pDate' => date('Y-m-d H:i:s')));
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
Example #7
0
 function nxs_doPublishToFB($postID, $options)
 {
     global $ShownAds;
     $ntCd = 'FB';
     $ntCdL = 'fb';
     $ntNm = 'Facebook';
     $dsc = '';
     $vidURL = '';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     if (!class_exists('nxs_class_SNAP_FB')) {
         nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No Facebook API Lib Detected', '');
         return "No Facebook API Lib Detected";
     }
     $fbWhere = 'feed';
     $page_id = $options['fbPgID'];
     if (isset($ShownAds)) {
         $ShownAdsL = $ShownAds;
     }
     $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName']));
     //## Some Common stuff
     if (empty($options['postType']) && !empty($options['fbPostType'])) {
         $options['postType'] = $options['fbPostType'];
         unset($options['fbPostType']);
     }
     //## Compatibility with v <3.2
     if (empty($options['postType']) && !empty($options['PostType'])) {
         $pt = $options['PostType'];
         unset($options['PostType']);
         $options['postType'] = $pt;
     }
     //## Compatibility with v <3.2
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#0000FF">Facebook</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $options['pType']);
             return;
         }
     }
     //## Make the post
     if (isset($options['qTLng'])) {
         $lng = $options['qTLng'];
     } else {
         $lng = '';
     }
     if (!isset($options['fbAppPageAuthToken'])) {
         $options['fbAppPageAuthToken'] = '';
     }
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     //## Initiate Posting Array
     $message = array('message' => '', 'link' => '', 'title' => '', 'description' => '', 'imageURL' => '', 'videoURL' => '', 'siteName' => $blogTitle);
     $imgURL = '';
     if ($postID == '0') {
         $options['fbMsgFormat'] = 'Test Post, Please Ignore';
         $dsc = 'Test Post, Description';
         $urlTitle = 'Test Post - Title';
         $urlToGo = home_url();
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $msg = nsFormatMessage($options['fbMsgFormat'], $postID, $addParams);
         $fbPostType = $options['postType'];
         if ($fbPostType == 'A') {
             $fbPostType = (int) $options['fbAttch'] == 2 ? 'S' : 'A';
         }
         $isAttachVidFB = $options['fbAttchAsVid'];
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? nxs_doQTrans($post->post_title, $lng) : '') . ' |' . $options['pType'];
         if ($fbPostType == 'A') {
             $imgURL = nxs_getPostImage($postID, 'medium');
         }
         // prr($options); echo "PP - ".$postID; prr($src);
         if ($fbPostType == 'I' || $fbPostType == 'S') {
             $imgURL = nxs_getPostImage($postID, 'full');
         }
         // prr($options); echo "PP - ".$postID; prr($src);
         if ($fbPostType == 'A' || $fbPostType == 'S') {
             //## AUTO - Get Post Descr from SEO Plugins or make it.
             if (trim($options['fbMsgAFrmt']) != '') {
                 $dsc = nsFormatMessage($options['fbMsgAFrmt'], $postID, $addParams);
             } else {
                 if (function_exists('aioseop_mrt_fix_meta') && $dsc == '') {
                     $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
                 }
                 if (function_exists('wpseo_admin_init') && $dsc == '') {
                     $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
                 }
                 if (function_exists('wpseo_admin_init') && $dsc == '') {
                     $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
                 }
                 if ($dsc == '') {
                     $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)));
                 }
                 if ($dsc == '') {
                     $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
                 }
                 if ($dsc == '') {
                     $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)));
                 }
                 if ($dsc == '') {
                     $dsc = trim(nxs_doQTrans($post->post_content, $lng));
                 }
                 if ($dsc == '') {
                     $dsc = get_bloginfo('description');
                 }
             }
             $dsc = strip_tags(strip_shortcodes($dsc));
             $dsc = nxs_decodeEntitiesFull($dsc);
             $dsc = nsTrnc($dsc, 900, ' ');
         }
         $msg = str_replace('<br>', "\n", $msg);
         $msg = str_replace('<br/>', "\n", $msg);
         $msg = str_replace('<br />', "\n", $msg);
         $msg = str_ireplace('<3', '&lt;3', $msg);
         $msg = str_ireplace('<(', '&lt;(', $msg);
         //## FB Smiles FIX.
         $msg = strip_tags($msg);
         $msg = nxs_decodeEntitiesFull($msg);
         $msg = str_ireplace('&#039;', "'", $msg);
         $msg = str_ireplace('&039;', "'", $msg);
         $msg = str_ireplace('&#39;', "'", $msg);
         $msg = str_ireplace('<3', '&lt;3', $msg);
         $msg = str_ireplace('<(', '&lt;(', $msg);
         //## FB Smiles FIX 2.
         if ($isAttachVidFB == '1') {
             $vids = nsFindVidsInPost($post, false);
             if (count($vids) > 0) {
                 if (strlen($vids[0]) == 11) {
                     $vidURL = 'http://www.youtube.com/v/' . $vids[0];
                     $imgURL = nsGetYTThumb($vids[0]);
                 }
                 if (strlen($vids[0]) == 8) {
                     $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id=' . $vids[0] . '&autoplay=1';
                     $apiURL = "http://vimeo.com/api/v2/video/" . $vids[0] . ".json?callback=showThumb";
                     $json = wp_remote_get($apiURL);
                     if (!is_wp_error($json)) {
                         $json = $json['body'];
                         $json = str_replace('showThumb(', '', $json);
                         $json = str_replace('])', ']', $json);
                         $json = json_decode($json, true);
                         $imgURL = $json[0]['thumbnail_large'];
                     }
                 }
             }
         }
         if (trim($options['imgToUse']) != '') {
             $imgURL = $options['imgToUse'];
         }
         if (preg_match("/noImg.\\.png/i", $imgURL)) {
             $imgURL = 'http://www.noimage.faketld';
         }
         //$imgURL = 'http://cdn.gtln.us/img/t1x1.gif';
         //## MyURL - URLToGo code
         if (!isset($options['urlToUse']) || trim($options['urlToUse']) == '') {
             $myurl = trim(get_post_meta($postID, 'snap_MYURL', true));
         }
         if ($myurl != '') {
             $options['urlToUse'] = $myurl;
         }
         if (isset($options['urlToUse']) && trim($options['urlToUse']) != '') {
             $urlToGo = $options['urlToUse'];
             $options['useFBGURLInfo'] = true;
         } else {
             $urlToGo = get_permalink($postID);
         }
         if ($addParams != '') {
             $urlToGo .= (strpos($urlToGo, '?') !== false ? '&' : '?') . $addParams;
         }
         //prr($options);
         $urlTitle = nxs_doQTrans($post->post_title, $lng);
         $options['fbMsgFormat'] = $msg;
         $urlTitle = strip_tags(strip_shortcodes($urlTitle));
     }
     $message = array('url' => $urlToGo, 'urlTitle' => $urlTitle, 'urlDescr' => $dsc, 'imageURL' => $imgURL, 'videoURL' => $vidURL, 'siteName' => $blogTitle);
     if (isset($ShownAds)) {
         $ShownAds = $ShownAdsL;
     }
     // FIX for the quick-adsense plugin
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_FB();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Process Results
     if (!is_array($ret) || $ret['isPosted'] != '1') {
         //## Error
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         // ## All Good - log it.
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your ' . $logNT . ' Page. ', 'nxs_snap');
         } else {
             nxs_addToRI($postID);
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'pgID' => $ret['postID'], 'pDate' => date('Y-m-d H:i:s')));
             $extInfo .= ' | <a href="' . $ret['postURL'] . '" target="_blank">Post Link</a>';
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
Example #8
0
 function nxs_doPublishToTR($postID, $options)
 {
     $ntCd = 'TR';
     $ntCdL = 'tr';
     $ntNm = 'Tumblr';
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTR',  array($postID, $options));
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#014A76">Tumblr</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $options['pType']);
             return;
         }
     }
     //## Format
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $msg = 'Test Post from ' . $blogTitle;
         $msgT = 'Test Post from ' . $blogTitle;
         $options['trPostType'] == 'T';
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $trMsgFormat = $options['trMsgFormat'];
         $msg = nsFormatMessage($trMsgFormat, $postID);
         $trMsgTFormat = $options['trMsgTFormat'];
         $msgT = nsFormatMessage($trMsgTFormat, $postID);
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
     }
     //prr($options); die();
     //## Post
     require_once 'apis/trOAuth.php';
     $consumer_key = $options['trConsKey'];
     $consumer_secret = $options['trConsSec'];
     $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']);
     //prr($options);
     $trURL = trim(str_ireplace('http://', '', $options['trURL']));
     if (substr($trURL, -1) == '/') {
         $trURL = substr($trURL, 0, -1);
     }
     $tggs = array();
     if ($options['trInclTags'] == '1') {
         $t = wp_get_post_tags($postID);
         $tggs = array();
         foreach ($t as $tagA) {
             $tggs[] = $tagA->name;
         }
         $tags = implode(',', $tggs);
     }
     if ($options['trInclCats'] == '1') {
         $t = wp_get_post_categories($postID);
         foreach ($t as $c) {
             $cat = get_category($c);
             $tggs[] = $cat->name;
         }
         $tags = implode(',', $tggs);
     }
     $postDate = ($post->post_date_gmt != '0000-00-00 00:00:00' ? $post->post_date_gmt : gmdate("Y-m-d H:i:s", strtotime($post->post_date))) . " GMT";
     //## Adds date to Tumblr post. Thanks to Kenneth Lecky
     $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title . ' |' . $options['pType'];
     $postArr = array('tags' => $tags, 'date' => $postDate);
     if ($options['trPostType'] == 'V') {
         $vids = nsFindVidsInPost($post);
         if (count($vids) > 0) {
             $ytUrl = $vids[0];
         }
         if (trim($ytUrl) == '') {
             $options['trPostType'] = 'T';
         }
     }
     if ($options['trPostType'] == 'U') {
         $aud = nsFindAudioInPost($post);
         if (count($aud) > 0) {
             $aUrl = $aud[0];
         }
         if (trim($aUrl) == '') {
             $options['trPostType'] = 'T';
         }
     }
     if ($options['trPostType'] == 'I') {
         $imgURL = nxs_getPostImage($postID, 'large', $options['trDefImg']);
         if (trim($imgURL) == '') {
             $options['trPostType'] = 'T';
         }
     }
     if ($options['trPostType'] == 'I') {
         $postArr['type'] = 'photo';
         $postArr['caption'] = $msg;
         $postArr['source'] = $imgURL;
         if (!isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') {
             $postArr['link'] = get_permalink($postID);
         } elseif ($options['cImgURL'] == 'S') {
             $postArr['link'] = get_permalink($postID);
             $postArr['link'] = nxs_mkShortURL($postArr['link']);
         }
     } elseif ($options['trPostType'] == 'U') {
         $postArr['type'] = 'audio';
         $postArr['caption'] = $msg;
         $postArr['external_url'] = $aUrl;
     } elseif ($options['trPostType'] == 'V') {
         $postArr['type'] = 'video';
         $postArr['caption'] = $msg;
         $embedTxt = '<iframe width="560" height="315" src="http://www.youtube.com/embed/' . $ytUrl . '" frameborder="0" allowfullscreen></iframe>';
         $postArr['embed'] = $embedTxt;
     } else {
         $postArr['title'] = $msgT;
         $postArr['type'] = 'text';
         $postArr['source'] = get_permalink($postID);
         $postArr['body'] = $msg;
     }
     $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/" . $trURL . "/post", $postArr);
     // prr($postinfo);  prr($postArr);
     $code = $postinfo->meta->status;
     // echo "XX".print_r($code);  prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
     if ($code == 201) {
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo 'OK - Message Posted, please see your Tumblr  Page. <br/> Result:';
             prr($postinfo->meta);
         } else {
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
             nxs_metaMarkAsPosted($postID, 'TR', $options['ii'], array('isPosted' => '1', 'pgID' => $postinfo->response->id, 'pDate' => date('Y-m-d H:i:s')));
         }
     } else {
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($postinfo, true), $extInfo);
         if ($postID == '0') {
             prr($postinfo);
         }
         $code .= " - " . $postinfo->meta->msg . $postinfo->errmsg;
     }
     return $code;
 }
Example #9
0
 function nsFindImgsInPost($post, $advImgFnd = false)
 {
     global $ShownAds;
     if (isset($ShownAds)) {
         $ShownAdsL = $ShownAds;
     }
     if ($advImgFnd) {
         $postCnt = apply_filters('the_content', $post->post_content);
     } else {
         $postCnt = $post->post_content;
     }
     $postImgs = array();
     //$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postCnt, $matches ); if ($output === false){return false;}
     //$postCnt = str_replace("'",'"',$postCnt); $output = preg_match_all( '/src="([^"]*)"/', $postCnt, $matches ); if ($output === false){return false;}
     $postCnt = str_replace("'", '"', $postCnt);
     $output = preg_match_all('/< *img[^>]*src *= *["\']?([^"\']*)/i', $postCnt, $matches);
     // prr($matches);
     if ($output === false || $output == 0) {
         $vids = nsFindVidsInPost($post, $advImgFnd == false);
         if (count($vids) > 0) {
             $postImgs[] = 'http://img.youtube.com/vi/' . $vids[0] . '/0.jpg';
         } else {
             return false;
         }
     } else {
         foreach ($matches[1] as $match) {
             if (!preg_match('/^https?:\\/\\//', $match)) {
                 $match = site_url('/') . ltrim($match, '/');
             }
             $postImgs[] = $match;
         }
         if (isset($ShownAds)) {
             $ShownAds = $ShownAdsL;
         }
     }
     return $postImgs;
 }
 function nxs_doPublishToGP($postID, $options)
 {
     $ntCd = 'GP';
     $ntCdL = 'gp';
     $ntNm = 'Google+';
     global $plgn_NS_SNAutoPoster;
     $ytCode = '';
     $imgURL = '';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     if (!class_exists('nxsAPI_GP') || defined('d1') && d1 == 1) {
         nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', '');
         return "No G+ API Lib Detected";
     }
     $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName']));
     if (empty($options['imgToUse'])) {
         $options['imgToUse'] = '';
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#800000">Google+</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $uqID);
             return;
         }
     }
     $message = array('message' => '', 'link' => '', 'imageURL' => '', 'videoURL' => '', 'noImg' => false);
     $isNoImg = false;
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $options['gpMsgFormat'] = "Test Post from " . htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES) . " - " . home_url();
         $message['url'] = home_url();
     } else {
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $gpMsgFormat = $options['gpMsgFormat'];
         $gpPostType = $options['postType'];
         $msg = nsFormatMessage($gpMsgFormat, $postID, $addParams);
         $options['gpMsgFormat'] = $msg;
         $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? $post->post_title : '');
         if ($gpPostType == 'I') {
             $vids = nsFindVidsInPost($post, false);
             if (count($vids) > 0) {
                 $ytCode = $vids[0];
             }
             /* if (trim($ytCode)=='') $options['trPostType']='T'; /* What is it? */
         }
         if ($gpPostType == 'A') {
             if (trim($options['imgToUse']) != '') {
                 $imgURL = $options['imgToUse'];
             } else {
                 $imgURL = nxs_getPostImage($postID, 'medium');
             }
         }
         if ($gpPostType == 'I') {
             if (trim($options['imgToUse']) != '') {
                 $imgURL = $options['imgToUse'];
             } else {
                 $imgURL = nxs_getPostImage($postID, 'full');
             }
         }
         if (preg_match("/noImg.\\.png/i", $imgURL)) {
             $imgURL = '';
             $isNoImg = true;
         }
         //## MyURL - URLToGo code
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
         $message = array('url' => $urlToGo, 'imageURL' => $imgURL, 'videoCode' => $ytCode, 'noImg' => $isNoImg);
         //prr($message); die();
     }
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_GP();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Process Results
     if (!is_array($ret) || $ret['isPosted'] != '1') {
         //## Error
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         // ## All Good - log it.
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your ' . $logNT . ' Page. ', 'nxs_snap');
         } else {
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'pgID' => $ret['postID'], 'pDate' => date('Y-m-d H:i:s')));
             $extInfo .= ' | <a href="' . $ret['postURL'] . '" target="_blank">Post Link</a>';
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
Example #11
0
 function nxs_doPublishToVK($postID, $options)
 {
     global $ShownAds, $nxs_vkCkArray;
     $ntCd = 'VK';
     $ntCdL = 'vk';
     $ntNm = 'vKontakte(VK)';
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToVK',  array($postID, $options));
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#000080">vKontakte</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $options['pType']);
             return;
         }
     }
     $email = $options['uName'];
     $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass'];
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $link = home_url();
         $msg = 'Test Link from ' . $link;
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $msgFormat = $options['msgFrmt'];
         $msg = strip_tags(nsFormatMessage($msgFormat, $postID));
         $link = get_permalink($postID);
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
     }
     $dusername = $options['uName'];
     $postType = $options['postType'];
     //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
     $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title . ' |' . $options['pType'];
     $imgURL = nxs_getPostImage($postID);
     $vids = nsFindVidsInPost($post);
     if (count($vids) > 0) {
         if (strlen($vids[0]) == 11) {
             $vidURL = 'http://www.youtube.com/watch?v=' . $vids[0];
             $imgURL = 'http://img.youtube.com/vi/' . $vids[0] . '/maxresdefault.jpg';
         }
         if (strlen($vids[0]) == 8) {
             $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id=' . $vids[0] . '&autoplay=1';
             //$mssg['source'] = 'http://player.vimeo.com/video/'.$vids[0];
             $apiURL = "http://vimeo.com/api/v2/video/" . $vids[0] . ".json?callback=showThumb";
             $json = wp_remote_get($apiURL);
             if (!is_wp_error($json)) {
                 $json = $json['body'];
                 $json = str_replace('showThumb(', '', $json);
                 $json = str_replace('])', ']', $json);
                 $json = json_decode($json, true);
                 $imgURL = $json[0]['thumbnail_large'];
             }
         }
     }
     $msgOpts = array();
     $msgOpts['uid'] = $options['vkPgID'];
     // if ($link!='') $msgOpts['link'] = $link;
     if ($vidURL != '' && $postType == "I") {
         $postType = 'A';
         $link = $vidURL;
         $msgOpts['vID'] = $vids[0];
     }
     if ($postType == 'I' && trim($imgURL) == '') {
         $postType = 'T';
     }
     $msgOpts['type'] = $postType;
     if ($postType == 'A' && $link != '') {
         //## Login
         if (isset($options['vkSvC'])) {
             $nxs_vkCkArray = maybe_unserialize($options['vkSvC']);
         }
         $loginError = true;
         if (is_array($nxs_vkCkArray)) {
             $loginError = nxs_doCheckVK();
         }
         if ($loginError != false) {
             $loginError = nxs_doConnectToVK($email, $pass);
         }
         if (serialize($nxs_vkCkArray) != $options['vkSvC']) {
             global $plgn_NS_SNAutoPoster;
             $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
             if (isset($options['ii']) && $options['ii'] !== '') {
                 $gOptions['vk'][$options['ii']]['vkSvC'] = serialize($nxs_vkCkArray);
                 update_option('NS_SNAutoPoster', $gOptions);
             } else {
                 foreach ($gOptions['vk'] as $ii => $gpn) {
                     $result = array_diff($options, $gpn);
                     if (!is_array($result) || count($result) < 1) {
                         $gOptions['vk'][$ii]['vkSvC'] = serialize($nxs_vkCkArray);
                         update_option('NS_SNAutoPoster', $gOptions);
                         break;
                     }
                 }
             }
         }
         if ($loginError !== false) {
             if ($postID == '0') {
                 prr($loginError);
             }
             nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($loginError, true) . " - BAD USER/PASS", $extInfo);
             return " -= BAD USER/PASS =- ";
         }
         //## Post
         if (trim($fbMsgAFormat) != '') {
             $dsc = nsFormatMessage($fbMsgAFormat, $postID);
         } else {
             if (function_exists('aioseop_mrt_fix_meta') && $dsc == '') {
                 $dsc = trim(get_post_meta($postID, '_aioseop_description', true));
             }
             if (function_exists('wpseo_admin_init') && $dsc == '') {
                 $dsc = trim(get_post_meta($postID, '_yoast_wpseo_opengraph-description', true));
             }
             if (function_exists('wpseo_admin_init') && $dsc == '') {
                 $dsc = trim(get_post_meta($postID, '_yoast_wpseo_metadesc', true));
             }
             if ($dsc == '') {
                 $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)));
             }
             if ($dsc == '') {
                 $dsc = trim(nxs_doQTrans($post->post_excerpt, $lng));
             }
             if ($dsc == '') {
                 $dsc = trim(apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)));
             }
             if ($dsc == '') {
                 $dsc = trim(nxs_doQTrans($post->post_content, $lng));
             }
             if ($dsc == '') {
                 $dsc = get_bloginfo('description');
             }
         }
         $dsc = strip_tags($dsc);
         $dsc = nxs_decodeEntitiesFull($dsc);
         $dsc = nsTrnc($dsc, 900, ' ');
         $msgOpts['url'] = $link;
         $msgOpts['urlTitle'] = nxs_doQTrans($post->post_title, $lng);
         $msgOpts['urlDesc'] = $dsc;
         $msgOpts['imgURL'] = $imgURL;
         $ret = nxs_doPostToVK($msg, $options['url'], $msgOpts);
         //  prr($ret);
     }
     //prr($postType);
     if ($postType == 'I') {
         $imgUpld = nxs_uplImgtoVK($imgURL, $options);
         if (is_object($imgUpld)) {
             $imgID = $imgUpld->id;
             $atts[] = $imgID;
         }
     }
     if ($postType != 'A') {
         if ($options['addBackLink'] == '1') {
             $atts[] = $link;
         }
         if (is_array($atts)) {
             $atts = implode(',', $atts);
         }
         $postUrl = 'https://api.vkontakte.ru/method/wall.post?owner_id=' . $options['pgIntID'] . '&access_token=' . $options['vkAppAuthToken'] . '&from_group=1&message=' . urlencode($msg) . '&attachment=' . urlencode($atts);
         $response = wp_remote_get($postUrl);
         // prr($atts); prr($postUrl);
         if (is_wp_error($response) || is_object($response) && isset($response->errors) || is_array($response) && stripos($response['body'], '"error":') !== false) {
             $ret = $response['body'];
         } else {
             $respJ = json_decode($response['body'], true);
             $ret = array("code" => "OK", "post_id" => $options['pgIntID'] . '_' . $respJ['response']['post_id']);
         }
     }
     if (is_array($ret) && $ret['code'] == 'OK') {
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo ' OK - Message Posted, please see your VK Page ';
         } else {
             nxs_metaMarkAsPosted($postID, 'VK', $options['ii'], array('isPosted' => '1', 'pgID' => $ret['post_id'], 'pDate' => date('Y-m-d H:i:s')));
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
             return 200;
         }
     } else {
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     }
 }
Example #12
0
 function nxs_doPublishToYT($postID, $options)
 {
     $ntCd = 'YT';
     $ntCdL = 'yt';
     $ntNm = 'YouTube';
     global $nxs_gCookiesArr;
     // $backtrace = debug_backtrace(); nxs_addToLogN('W', 'Enter', $ntCd, 'I am here - '.$ntCd."|".print_r($backtrace, true), '');
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToYT',  array($postID, $options));
     if (!function_exists('doConnectToGooglePlus2') || !function_exists('doPostToGooglePlus2')) {
         nxs_addToLogN('E', 'Error', $ntCd, '-=ERROR=- No G+ API Lib Detected', '');
         return "No G+ API Lib Detected";
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#800000">YouTube</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) {
         $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true);
         if ($snap_isAutoPosted != '2') {
             sleep(5);
             nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $uqID);
             return;
         }
     }
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
     } else {
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $post = get_post($postID);
         if (!$post) {
             return;
         }
     }
     $ytMsgFormat = $options['ytMsgFormat'];
     $msg = nsFormatMessage($ytMsgFormat, $postID);
     // prr($msg); echo $postID;
     $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title;
     $email = $options['ytUName'];
     $pass = substr($options['ytPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['ytPass'], 5)) : $options['ytPass'];
     $loginError = doConnectToGooglePlus2($email, $pass, 'YT');
     if ($loginError !== false) {
         if ($postID == '0') {
             echo $loginError;
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($loginError, true) . " - BAD USER/PASS", $extInfo);
         return "BAD USER/PASS";
     }
     $url = get_permalink($postID);
     if (trim($url) == '') {
         $url = home_url();
     }
     $vids = nsFindVidsInPost($post);
     if (count($vids) > 0) {
         $vUrl = $vids[0];
     }
     $ret = doPostToYouTube($msg, $options['ytPageID'], $vUrl);
     //prr($ret);
     if ($ret == 'OK') {
         $ret = array("code" => "OK", "post_id" => '');
     }
     if (!is_array($ret) && $ret != 'OK') {
         if ($postID == '0') {
             prr($ret);
         }
         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo);
     } else {
         if ($postID == '0') {
             nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted ');
             echo _e('OK - Message Posted, please see your YouTube Page', 'nxs_snap');
         } else {
             nxs_metaMarkAsPosted($postID, 'YT', $options['ii'], array('isPosted' => '1', 'pgID' => $ret['post_id'], 'pDate' => date('Y-m-d H:i:s')));
             nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo);
         }
     }
     if ($ret['code'] == 'OK') {
         return 200;
     } else {
         return $ret;
     }
 }