コード例 #1
0
 function nxs_doPublishToFL($postID, $options)
 {
     $ntCd = 'FL';
     $ntCdL = 'fl';
     $ntNm = 'Flickr';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     $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">Flickr</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' . ' |');
             return;
         }
     }
     $message = array('message' => '', 'link' => '', 'imageURL' => '', 'videoURL' => '', 'announce' => '');
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $message['description'] = 'Test Post, Description';
         $message['title'] = 'Test Post - Title';
         $message['url'] = home_url();
         $message['tags'] = '';
         if ($options['defImg'] != '') {
             $imgURL = $options['defImg'];
         } else {
             $imgURL = "http://direct.gtln.us/img/nxs/NXS-Lama.jpg";
         }
         $message['imageURL'] = $imgURL;
     } else {
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $isNoImg = false;
         $tags = '';
         $options['msgFrmt'] = nsFormatMessage($options['msgFrmt'], $postID, $addParams);
         $options['msgTFrmt'] = nsFormatMessage($options['msgTFrmt'], $postID, $addParams);
         $tggs = array();
         if ($options['inclTags'] == '1') {
             $t = wp_get_post_tags($postID);
             $tggs = array();
             foreach ($t as $tagA) {
                 $tggs[] = $tagA->name;
             }
             $tags = '"' . implode('" "', $tggs) . '"';
         }
         $imgURL = nxs_getPostImage($postID, 'full');
         if (preg_match("/noImg.\\.png/i", $imgURL)) {
             $imgURL = '';
             $isNoImg = true;
         }
         $options = nxs_getURL($options, $postID);
         $urlToGo = $options['urlToUse'];
         $message = array('url' => $urlToGo, 'imageURL' => $imgURL, 'noImg' => $isNoImg, 'tags' => $tags);
         $lat = get_post_meta($postID, 'geo_latitude', true);
         $long = get_post_meta($postID, 'geo_longitude', true);
         if (!empty($lat) && !empty($long)) {
             $message['latitude'] = $lat;
             $message['longitude'] = $long;
         }
         $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? $post->post_title : '');
     }
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_FL();
     $ret = $ntToPost->doPostToNT($options, $message);
     //prr($ret);
     //## 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);
         }
     }
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
コード例 #2
0
 function nxs_doPublishToLI($postID, $options)
 {
     global $nxs_gCookiesArr;
     $ntCd = 'LI';
     $ntCdL = 'li';
     $ntNm = 'LinkedIn';
     $urlDescr = '';
     $myurl = '';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLI',  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'] = '';
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#000058">LinkedIn</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;
         }
     }
     $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
     if ($blogTitle == '') {
         $blogTitle = home_url();
     }
     $imgURL = '';
     // prr($options);
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $options['liMsgFormatT'] = 'Test Post from ' . $blogTitle;
         $urlToGo = home_url();
         $options['liMsgFormat'] = 'Test Post from ' . $blogTitle . " " . $urlToGo;
         $title = $blogTitle;
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $options['liMsgFormat'] = nsFormatMessage($options['liMsgFormat'], $postID, $addParams);
         $options['liMsgFormatT'] = nsTrnc(nsFormatMessage($options['liMsgFormatT'], $postID, $addParams), 200);
         //## MyURL - URLToGo code
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
         $title = nsTrnc($post->post_title, 200);
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         if (empty($options['postType'])) {
             if ((int) $options['liAttch'] == 1 || $isNew) {
                 $options['postType'] = 'A';
             }
         }
         if ($options['postType'] == 'A' || $options['postType'] == 'I') {
             if (trim($options['liMsgAFrmt']) != '') {
                 $urlDescr = nsFormatMessage($options['liMsgAFrmt'], $postID, $addParams);
             } else {
                 $urlDescr = trim(apply_filters('the_content', $post->post_excerpt));
                 if ($urlDescr == '') {
                     $urlDescr = apply_filters('the_content', $post->post_content);
                 }
             }
             if (trim($options['imgToUse']) != '') {
                 $imgURL = $options['imgToUse'];
             } else {
                 $imgURL = nxs_getPostImage($postID, 'full');
             }
             if (preg_match("/noImg.\\.png/i", $imgURL)) {
                 $imgURL = '';
             }
             $urlDescr = strip_tags($urlDescr);
             $urlDescr = nxs_decodeEntitiesFull($urlDescr);
             $urlDescr = nxs_html_to_utf8($urlDescr);
             $urlDescr = nsTrnc($urlDescr, 300);
         }
     }
     $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? $post->post_title : '');
     //$images = array(nxs_getPostImage($postID, 'thumb'), nxs_getPostImage($postID, 'medium'), nxs_getPostImage($postID, 'full'), nxs_getPostImage($postID, 'original'));
     $message = array('url' => $urlToGo, 'surl' => $urlToGo, 'urlDescr' => $urlDescr, 'urlTitle' => $title, 'title' => $title, 'imageURL' => $imgURL, 'videoCode' => '', 'videoURL' => '', 'siteName' => $blogTitle, 'cats' => '', 'authorName' => '');
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_LI();
     $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 {
         $extInfo .= ' | ' . $ret['postID'];
         // ## 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. ', 'social-networks-auto-poster-facebook-twitter-g');
         } else {
             nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted' => '1', 'postID' => $ret['postID'], 'postURL' => $ret['postURL'], 'pgID' => $ret['postID'], 'pDate' => date('Y-m-d H:i:s')));
             if (!empty($ret['postURL'])) {
                 $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);
     }
 }
コード例 #3
0
 function nxs_doPublishToDL($postID, $options)
 {
     $ntCd = 'DL';
     $ntCdL = 'dl';
     $ntNm = 'Delicious';
     global $plgn_NS_SNAutoPoster;
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDL',  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();
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#000080">Delicious</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');
             return;
         }
     }
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $urlToGo = home_url();
         $msgT = 'Test Link from ' . $urlToGo;
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $options['dlMsgTFormat'] = nsFormatMessage($options['dlMsgTFormat'], $postID);
         $options['dlMsgFormat'] = nsFormatMessage($options['dlMsgFormat'], $postID);
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         //## MyURL - URLToGo code
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
     }
     $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? $post->post_title : '');
     //## Create and Format message
     $t = wp_get_post_tags($postID);
     $tggs = array();
     foreach ($t as $tagA) {
         $tggs[] = $tagA->name;
     }
     $tags = implode(',', $tggs);
     //  $tags = str_replace(' ','+',$tags);
     $message = array('url' => $urlToGo, 'surl' => $urlToGo, 'siteName' => $blogTitle, 'tags' => $tags);
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_DL();
     $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. ', 'social-networks-auto-poster-facebook-twitter-g');
         } 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 (!empty($ret['isPosted']) && $ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
コード例 #4
0
ファイル: vk.php プロジェクト: brettex/pspark
 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);
     }
 }
コード例 #5
0
 function nxs_doPublishToRD($postID, $options)
 {
     $ntCd = 'RD';
     $ntCdL = 'rd';
     $ntNm = 'Reddit';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#800000">Reddit</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName']));
     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' . ' |');
             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['url'] = home_url();
     } else {
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $rdPostType = $options['postType'];
         $options['rdTitleFormat'] = nsFormatMessage($options['rdTitleFormat'], $postID);
         $options['rdTextFormat'] = nsFormatMessage($options['rdTextFormat'], $postID);
         // prr($msg); echo $postID;
         $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title;
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
         $message = array('message' => $options['rdTextFormat'], 'url' => $urlToGo, 'title' => $options['rdTitleFormat']);
     }
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_RD();
     $ret = $ntToPost->doPostToNT($options, $message);
     // echo "~~~"; prr($ret); echo "+++";
     //## 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. ', 'social-networks-auto-poster-facebook-twitter-g');
         } 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);
     }
 }
コード例 #6
0
ファイル: tr.php プロジェクト: brettex/pspark
 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);
     }
 }
コード例 #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
     //## Compatibility with v <3.4.15
     if (empty($options['atchUse'])) {
         $options['atchUse'] = 'F';
     }
     if (!empty($options['useFBGURLInfo']) && $options['useFBGURLInfo'] == '1') {
         $options['atchUse'] = 'F';
     }
     if (isset($options['useFBGURLInfo']) && $options['useFBGURLInfo'] == '0') {
         $options['atchUse'] = 'A';
     }
     if (!empty($options['fbMsgAFrmt'])) {
         $options['atchUse'] = 'M';
     }
     if (!empty($options['fbMsgAFrmt']) && empty($options['msgDAFrmt'])) {
         $options['msgDAFrmt'] = $options['fbMsgAFrmt'];
         $options['msgTAFrmt'] = '%TITLE%';
     }
     if (isset($options['fbAttchAsVid']) && $options['fbAttchAsVid'] == '1') {
         $options['fbAttchAsVid'] = 'A';
     }
     if (empty($options['fbAttchAsVid'])) {
         $options['fbAttchAsVid'] = 'N';
     }
     $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') && $options['atchUse'] != 'F') {
             //## AUTO - Get Post Descr from SEO Plugins or make it.
             if ($options['atchUse'] == 'M') {
                 $dsc = nsFormatMessage($options['msgDAFrmt'], $postID, $addParams);
                 $urlTitle = nsFormatMessage($options['msgTAFrmt'], $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(nxs_doQTrans($post->post_excerpt, $lng));
                 }
                 if ($dsc == '') {
                     $dsc = trim(nxs_doQTrans($post->post_content, $lng));
                 }
                 global $plgn_NS_SNAutoPoster;
                 $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
                 if (empty($gOptions['brokenCntFilters'])) {
                     $dsc = apply_filters('the_content', $dsc);
                 }
                 if ($dsc == '') {
                     $dsc = get_bloginfo('description');
                 }
                 $urlTitle = nxs_doQTrans($post->post_title, $lng);
             }
             $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 == 'V') {
             $vids = nsFindVidsInPost($post, false);
             if (count($vids) > 0) {
                 if (strlen($vids[0]) == 11) {
                     $options['urlToUse'] = 'http://youtu.be/' . $vids[0];
                 }
                 if (strlen($vids[0]) == 8 || strlen($vids[0]) == 9) {
                     $options['urlToUse'] = 'https://vimeo.com/' . $vids[0];
                 }
                 if (strlen($vids[0]) == 15) {
                     $options['urlToUse'] = 'https://www.facebook.com/video.php?v=' . $vids[0];
                 }
             }
         }
         if ($isAttachVidFB == 'A') {
             $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 || strlen($vids[0]) == 9) {
                     // $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
                     $vidURL = 'https://f.vimeocdn.com/p/flash/moogaloop/6.0.37/moogaloop.swf?autoplay=1&clip_id=' . $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('/**/', '', $json);
                         $json = str_replace('showThumb(', '', $json);
                         $json = str_replace('])', ']', $json);
                         $json = json_decode($json, true);
                         $imgURL = $json[0]['thumbnail_large'];
                     }
                 }
                 if (strlen($vids[0]) == 15) {
                     // $vidURL = 'https://secure.vimeo.com/moogaloop.swf?clip_id='.$vids[0].'&autoplay=1';
                     $vidURL = 'https://www.facebook.com/video.php?v=' . $vids[0];
                     $apiURL = "https://graph.facebook.com/" . $vids[0];
                     $json = wp_remote_get($apiURL);
                     if (!is_wp_error($json)) {
                         $json = $json['body'];
                         $json = json_decode($json, true);
                         $frmts = $json['format'];
                         $imgURL = array_pop($frmts);
                         $imgURL = $imgURL['picture'];
                     }
                 }
             }
         }
         if (!empty($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';
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
         $options['fbMsgFormat'] = $msg;
         if (!empty($urlTitle)) {
             $urlTitle = strip_tags(strip_shortcodes($urlTitle));
         }
     }
     $message = array('url' => $urlToGo, 'urlTitle' => $urlTitle, 'urlDescr' => $dsc, 'imageURL' => $imgURL, 'videoURL' => $vidURL, 'siteName' => $blogTitle);
     //   prr($message); die();
     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) || !isset($ret['isPosted']) || $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);
             if (!empty($ret['log']) && !empty($ret['log']['Warning'])) {
                 nxs_addToLogN('W', 'Warning', $logNT, $ret['log']['Warning'], $extInfo);
             }
         }
     }
     //## Return Result
     if (!empty($ret['isPosted']) && $ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
コード例 #8
0
ファイル: pn.php プロジェクト: brettex/pspark
 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));
     }
     if (empty($options['ck'])) {
         $options['ck'] = '';
     }
     // $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
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
         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);
     }
 }
コード例 #9
0
 function nxs_doPublishToSC($postID, $options)
 {
     global $plgn_NS_SNAutoPoster;
     $ntCd = 'SC';
     $ntCdL = 'sc';
     $ntNm = 'Scoop.It';
     if (!is_array($options)) {
         $options = maybe_unserialize(get_post_meta($postID, $options, true));
     }
     $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">Scoop.It</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['url'] = home_url();
     } else {
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $postType = $options['postType'];
         $isNoImg = false;
         $tags = '';
         $options['msgFrmt'] = nsFormatMessage($options['msgFrmt'], $postID, $addParams);
         $options['msgTFrmt'] = nsFormatMessage($options['msgTFrmt'], $postID, $addParams);
         $tggs = array();
         if ($options['inclTags'] == '1') {
             $t = wp_get_post_tags($postID);
             $tggs = array();
             foreach ($t as $tagA) {
                 $tggs[] = $tagA->name;
             }
             $tags = $tggs;
         }
         if ($postType == 'A') {
             if (trim($options['imgToUse']) != '') {
                 $imgURL = $options['imgToUse'];
             } else {
                 $imgURL = nxs_getPostImage($postID, 'medium');
             }
         }
         if ($postType == '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, 'noImg' => $isNoImg, 'tags' => $tags);
         $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? $post->post_title : '');
     }
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_SC();
     $ret = $ntToPost->doPostToNT($options, $message);
     //prr($ret);
     //## 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. ', 'social-networks-auto-poster-facebook-twitter-g');
         } 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);
         }
     }
     //## Return Result
     if ($ret['isPosted'] == '1') {
         return 200;
     } else {
         return print_r($ret, true);
     }
 }
コード例 #10
0
 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);
     }
 }
コード例 #11
0
ファイル: su.php プロジェクト: brettex/pspark
 function nxs_doPublishToSU($postID, $options)
 {
     global $nxs_suCkArray;
     $ntCd = 'SU';
     $ntCdL = 'su';
     $ntNm = 'StumbleUpon';
     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_doPublishToSU',  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();
     }
     $ii = $options['ii'];
     if (!isset($options['pType'])) {
         $options['pType'] = 'im';
     }
     if ($options['pType'] == 'sh') {
         sleep(rand(1, 10));
     }
     $logNT = '<span style="color:#000080">StumbleUpon</span> - ' . $options['nName'];
     $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true);
     $snap_ap = maybe_unserialize($snap_ap);
     /* Check is still nessesary or redo
        if ($options['reset'] != '1' && $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;
            }
        }
        */
     $suCat = $options['suCat'];
     // if (function_exists("get_post_thumbnail_id") ){ $src = wp_get_attachment_image_src(get_post_thumbnail_id($postID), 'thumbnail'); $src = $src[0];}
     if ($postID == '0') {
         echo "Testing ... <br/><br/>";
         $urlToGo = home_url();
         $options['suMsgFormat'] = 'Test Link from ' . $urlToGo;
     } else {
         $post = get_post($postID);
         if (!$post) {
             return;
         }
         $options['suMsgFormat'] = nsFormatMessage($options['suMsgFormat'], $postID, $addParams);
         nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1'));
         //## MyURL - URLToGo code
         $options = nxs_getURL($options, $postID, $addParams);
         $urlToGo = $options['urlToUse'];
     }
     $dusername = $options['suUName'];
     //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
     if ($options['suInclTags'] == '1') {
         $t = wp_get_post_tags($postID);
         $tggs = array();
         foreach ($t as $tagA) {
             $tggs[] = $tagA->name;
         }
         $tags = urlencode(implode(',', $tggs));
         $tags = str_replace(' ', '+', $tags);
     } else {
         $tags = '';
     }
     $extInfo = ' | PostID: ' . $postID . " - " . (isset($post) && is_object($post) ? $post->post_title : '');
     //## Post
     $message = array('siteName' => $blogTitle, 'tags' => $tags, 'url' => $urlToGo);
     //## Actual Post
     $ntToPost = new nxs_class_SNAP_SU();
     $ret = $ntToPost->doPostToNT($options, $message);
     //## Save Session
     if (serialize($nxs_suCkArray) != $options['suSvC']) {
         global $plgn_NS_SNAutoPoster;
         $gOptions = $plgn_NS_SNAutoPoster->nxs_options;
         if (isset($options['ii']) && $options['ii'] !== '') {
             $gOptions['su'][$options['ii']]['suSvC'] = serialize($nxs_suCkArray);
             update_option('NS_SNAutoPoster', $gOptions);
         } else {
             foreach ($gOptions['su'] as $ii => $gpn) {
                 $result = array_diff($options, $gpn);
                 if (!is_array($result) || count($result) < 1) {
                     $gOptions['su'][$ii]['suSvC'] = serialize($nxs_suCkArray);
                     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);
     }
 }