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); } }
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); } }
function nxs_doPublishToDI($postID, $options) { global $nxs_diCkArray; $ntCd = 'DI'; $ntCdL = 'di'; $ntNm = 'Diigo'; if (!is_array($options)) { $options = maybe_unserialize(get_post_meta($postID, $options, true)); } // if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToDI', 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">Diigo</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 (empty($postID)) { echo "Testing ... <br/><br/>"; $urlToGo = home_url(); $options['diMsgFormat'] = 'Test Message from ' . $urlToGo; $options['diMsgTFormat'] = 'Test Link from ' . $urlToGo; } else { $post = get_post($postID); $options = nxs_getURL($options, $postID, $addParams); $urlToGo = $options['urlToUse']; $options['diMsgFormat'] = nxs_decodeEntitiesFull(nsFormatMessage($options['diMsgFormat'], $postID, $addParams)); $options['diMsgTFormat'] = nxs_decodeEntitiesFull(nsFormatMessage($options['diMsgTFormat'], $postID, $addParams)); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1')); } $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_DI(); $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 (!empty($ret['isPosted']) && $ret['isPosted'] == '1') { return 200; } else { return print_r($ret, true); } }
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', '<3', $msg); $msg = str_ireplace('<(', '<(', $msg); //## FB Smiles FIX. $msg = strip_tags($msg); $msg = nxs_decodeEntitiesFull($msg); $msg = str_ireplace(''', "'", $msg); $msg = str_ireplace('&039;', "'", $msg); $msg = str_ireplace(''', "'", $msg); $msg = str_ireplace('<3', '<3', $msg); $msg = str_ireplace('<(', '<(', $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); } }
function nxs_doPublishToTW($postID, $options) { $ntCd = 'TW'; $ntCdL = 'tw'; $ntNm = 'Twitter'; $imgData = ''; $imgURL = ''; global $plgn_NS_SNAutoPoster, $nxs_urlLen; $nxs_urlLen = 0; if (!is_array($options)) { $options = maybe_unserialize(get_post_meta($postID, $options, true)); } //$backtrace = debug_backtrace(); nxs_addToLogN('W', 'Error', $logNT, 'I am here - '.$ntCd."|".print_r($backtrace, true), ''); //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTW', array($postID, $options)); $gOptions = $plgn_NS_SNAutoPoster->nxs_options; if (!empty($gOptions['nxsHTSpace'])) { $htS = $gOptions['nxsHTSpace']; } else { $htS = ''; } $addParams = nxs_makeURLParams(array('NTNAME' => $ntNm, 'NTCODE' => $ntCd, 'POSTID' => $postID, 'ACCNAME' => $options['nName'])); $ii = $options['ii']; if (!isset($options['pType'])) { $options['pType'] = 'im'; } if ($options['pType'] == 'sh') { sleep(rand(1, 10)); } $logNT = '<span style="color:#00FFFF">Twitter</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; } } $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle == '') { $blogTitle = home_url(); } $uln = 0; $extInfo = ' | PostID: ' . $postID; if ($options['attchImg'] == '1') { if (!empty($options['imgToUse'])) { $imgURL = $options['imgToUse']; } else { $imgURL = nxs_getPostImage($postID); } if (preg_match("/noImg.\\.png/i", $imgURL)) { $imgURL = ''; } if (trim($imgURL) == '') { $options['attchImg'] = 0; } else { $imgURL = str_replace(' ', '%20', $imgURL); $hdrsArr['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0'; $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'sslverify' => false); $imgData = wp_remote_get($imgURL, $advSet); if (is_wp_error($imgData) || empty($imgData['body']) || !empty($imgData['headers']['content-length']) && (int) $imgData['headers']['content-length'] < 200) { $options['attchImg'] = 0; nxs_addToLogN('E', 'Error', $logNT, 'Could not get image (' . $imgURL . '), will post without it - Error:' . print_r($imgData, true), $extInfo); } else { $imgData = $imgData['body']; } } } if ($options['attchImg'] == '1' && $imgData != '') { $twLim = 117; } else { $twLim = 140; } if ($postID == '0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from ' . nsTrnc($blogTitle, $twLim - 24) . " - " . rand(1, 155); $uln = nxs_strLen($msg); } else { $post = get_post($postID); if (!$post) { return; } $twMsgFormat = $options['twMsgFormat']; nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1')); $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title . ' |' . $options['pType']; if (stripos($twMsgFormat, '%URL%') !== false || stripos($twMsgFormat, '%SURL%') !== false) { $twLim = $twLim - 22; } if (stripos($twMsgFormat, '%AUTHORNAME%') !== false) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun); $twLim = $twLim - nxs_strLen($aun); } $noRepl = str_ireplace("%TITLE%", "", $twMsgFormat); $noRepl = str_ireplace("%SITENAME%", "", $noRepl); $noRepl = str_ireplace("%URL%", "", $noRepl); $noRepl = str_ireplace("%RAWEXCERPT%", "", $noRepl); $noRepl = str_ireplace("%SURL%", "", $noRepl); $noRepl = str_ireplace("%TEXT%", "", $noRepl); $noRepl = str_ireplace("%FULLTEXT%", "", $noRepl); $noRepl = str_ireplace("%EXCERPT%", "", $noRepl); $noRepl = str_ireplace("%ANNOUNCE%", "", $noRepl); $noRepl = str_ireplace("%AUTHORNAME%", "", $noRepl); $noRepl = str_ireplace("%TAGS%", "", $noRepl); $noRepl = str_ireplace("%CATS%", "", $noRepl); $noRepl = preg_replace('/%H?C(F|T)-[a-zA-Z0-9_]+%/', '', $noRepl); $twLim = $twLim - nxs_strLen($noRepl); // prr($noRepl); $pTitle = nxs_doQTrans($post->post_title); if ($post->post_excerpt != "") { $exrText = nxs_doQTrans($post->post_excerpt); } else { $exrText = nxs_doQTrans($post->post_content); } $pText = empty($gOptions['brokenCntFilters']) ? apply_filters('the_content', $exrText) : $exrText; $pRawText = nxs_doQTrans($post->post_content); $pFullText = empty($gOptions['brokenCntFilters']) ? apply_filters('the_content', $pRawText) : $pRawText; if (stripos($twMsgFormat, '%TAGS%') !== false || stripos($twMsgFormat, '%HTAGS%') !== false) { $t = wp_get_object_terms($postID, 'product_tag'); if (empty($t) || is_wp_error($pt) || !is_array($t)) { $t = wp_get_post_tags($postID); } $tggs = array(); foreach ($t as $tagA) { $frmTag = trim(str_replace(' ', $htS, preg_replace('/[^a-zA-Z0-9\\p{L}\\p{N}\\s]/u', '', trim(ucwords(str_ireplace('&', '', str_ireplace('&', '', $tagA->name))))))); if (preg_match('/\\b' . $frmTag . '\\b/iu', $pTitle)) { $pTitle = trim(preg_replace('/\\b' . $frmTag . '\\b/iu', '#' . $frmTag, $pTitle)); } if (preg_match('/\\b' . $frmTag . '\\b/iu', $pFullText)) { $pFullText = trim(preg_replace('/\\b' . $frmTag . '\\b/iu', '#' . $frmTag, $pFullText)); } if (preg_match('/\\b' . $frmTag . '\\b/iu', $pText)) { $pText = trim(preg_replace('/\\b' . $frmTag . '\\b/iu', '#' . $frmTag, $pText)); } if (preg_match('/\\b' . $frmTag . '\\b/iu', $pRawText)) { $pRawText = trim(preg_replace('/\\b' . $frmTag . '\\b/iu', '#' . $frmTag, $pRawText)); } if (stripos($twMsgFormat, '%TITLE%') !== false && preg_match('/\\b' . $frmTag . '\\b/i', $pTitle) || stripos($twMsgFormat, '%TEXT%') !== false && preg_match('/\\b' . $frmTag . '\\b/i', $pText) || stripos($twMsgFormat, '%EXCERPT%') !== false && preg_match('/\\b' . $frmTag . '\\b/i', $pText) || stripos($twMsgFormat, '%RAWEXCERPT%') !== false && preg_match('/\\b' . $frmTag . '\\b/i', $pText) || stripos($twMsgFormat, '%ANNOUNCE%') !== false && preg_match('/\\b' . $frmTag . '\\b/i', $pText) || stripos($twMsgFormat, '%FULLTEXT%') !== false && preg_match('/\\b' . $frmTag . '\\b/i', $pFullText) || stripos($twMsgFormat, '%RAWTEXT%') !== false && preg_match('/\\b' . $frmTag . '\\b/i', $pRawText)) { } else { $tggs[] = '#' . $frmTag; } } $tags = implode(' ', $tggs); $tgsTwLim = $twLim - 20; $tags = nsTrnc($tags, $tgsTwLim, " ", ""); $twMsgFormat = str_ireplace("%TAGS%", $tags, $twMsgFormat); $twMsgFormat = str_ireplace("%HTAGS%", $tags, $twMsgFormat); $twLim = $twLim - nxs_strLen($tags); } if (stripos($twMsgFormat, '%CATS%') !== false || stripos($twMsgFormat, '%HCATS%') !== false) { $t = wp_get_post_categories($postID); $ctts = array(); foreach ($t as $c) { $cat = get_category($c); //$frmTag = trim(str_replace(' ','', str_replace(' ',' ',str_ireplace('&','&',trim(ucwords($cat->name)))))); prr($frmTag); $frmTag = trim(str_replace(' ', $htS, preg_replace('/[^a-zA-Z0-9\\p{L}\\p{N}\\s]/u', '', trim(ucwords(str_ireplace('&', '', str_ireplace('&', '', $cat->name))))))); if (stripos($pTitle, $cat->name) !== false) { $pTitle = str_ireplace($cat->name, '#' . $frmTag, $pTitle); } elseif (stripos($pTitle, $frmTag) !== false) { $pTitle = str_ireplace($frmTag, '#' . $frmTag, $pTitle); } if (stripos($pText, $cat->name) !== false) { $pText = str_ireplace($cat->name, '#' . $frmTag, $pText); } elseif (stripos($pText, $frmTag) !== false) { $pText = str_ireplace($frmTag, '#' . $frmTag, $pText); } if (stripos($pFullText, $cat->name) !== false) { $pFullText = str_ireplace($cat->name, '#' . $frmTag, $pFullText); } elseif (stripos($pFullText, $frmTag) !== false) { $pFullText = str_ireplace($frmTag, '#' . $frmTag, $pFullText); } if (stripos($pRawText, $cat->name) !== false) { $pRawText = str_ireplace($cat->name, '#' . $frmTag, $pRawText); } elseif (stripos($pRawText, $frmTag) !== false) { $pRawText = str_ireplace($frmTag, '#' . $frmTag, $pRawText); } if (stripos($twMsgFormat, '%TITLE%') !== false && (stripos($pTitle, $cat->name) !== false || stripos($pTitle, $frmTag) !== false) || stripos($twMsgFormat, '%TEXT%') !== false && (stripos($pText, $cat->name) !== false || stripos($pText, $frmTag) !== false) || stripos($twMsgFormat, '%EXCERPT%') !== false && (stripos($pText, $cat->name) !== false || stripos($pText, $frmTag) !== false) || stripos($twMsgFormat, '%RAWEXCERPT%') !== false && (stripos($exrText, $cat->name) !== false || stripos($exrText, $frmTag) !== false) || stripos($twMsgFormat, '%ANNOUNCE%') !== false && (stripos($pText, $cat->name) !== false || stripos($pText, $frmTag) !== false) || stripos($twMsgFormat, '%FULLTEXT%') !== false && (stripos($pFullText, $cat->name) !== false || stripos($pFullText, $frmTag) !== false) || stripos($twMsgFormat, '%RAWTEXT%') !== false && (stripos($pRawText, $cat->name) !== false || stripos($pRawText, $frmTag) !== false)) { } else { $ctts[] = '#' . $frmTag; } } $cats = implode(' ', $ctts); $tgsTwLim = $twLim - 20; $cats = nsTrnc($cats, $tgsTwLim, " ", ""); $twMsgFormat = str_ireplace("%CATS%", $cats, $twMsgFormat); $twMsgFormat = str_ireplace("%HCATS%", $cats, $twMsgFormat); $twLim = $twLim - nxs_strLen($cats); } if (preg_match('/%H?CT-[a-zA-Z0-9_]+%/', $twMsgFormat)) { $msgA = explode('%CT', str_ireplace("%HCT", "%CT", $twMsgFormat)); $mout = ''; foreach ($msgA as $mms) { if (substr($mms, 0, 1) == '-' && stripos($mms, '%') !== false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = wp_get_post_terms($postID, $mGr, array("fields" => "names")); if (is_nxs_error($cfItem)) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . $mGr . '|' . print_r($cfItem, true), $extInfo); } else { $tggs = array(); foreach ($cfItem as $frmTag) { $frmTag = trim(str_replace(' ', $htS, preg_replace('/[^a-zA-Z0-9\\p{L}\\p{N}\\s]/u', '', trim(ucwords(str_ireplace('&', '', str_ireplace('&', '', $frmTag))))))); $tggs[] = '#' . $frmTag; } $cfItem = implode(' ', $tggs); $twLim = $twLim - nxs_strLen($cfItem); $mms = str_ireplace("-" . $mGr . "%", $cfItem, $mms); } } $mout .= $mms; } $twMsgFormat = $mout; } $twMsgFormat = str_ireplace(" ", " ", $twMsgFormat); if (stripos($twMsgFormat, '%TITLE%') !== false) { if (stripos($pTitle, '.co.uk') !== false) { $twLim = $twLim - 14; } if (stripos($pTitle, '.com') !== false) { $twLim = $twLim - 16; } if (stripos($pTitle, '.net') !== false) { $twLim = $twLim - 16; } if (stripos($pTitle, '.org') !== false) { $twLim = $twLim - 16; } $pTitle = html_entity_decode(strip_tags($pTitle), ENT_NOQUOTES, 'UTF-8'); //$ttlTwLim = $twLim-20; $ttlTwLim = $twLim; $pTitle = nsTrnc($pTitle, $ttlTwLim); $twMsgFormat = str_ireplace("%TITLE%", $pTitle, $twMsgFormat); $twLim = $twLim - nxs_strLen($pTitle); } if (stripos($twMsgFormat, '%SITENAME%') !== false) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $siteTitle = nsTrnc($siteTitle, $twLim); $twMsgFormat = str_ireplace("%SITENAME%", $siteTitle, $twMsgFormat); $twLim = $twLim - nxs_strLen($siteTitle); } if (stripos($twMsgFormat, '%TEXT%') !== false) { $pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 140, " ", "..."); $pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%TEXT%", $pText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pText); } if (stripos($twMsgFormat, '%EXCERPT%') !== false) { $pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 140, " ", "..."); $pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%EXCERPT%", $pText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pText); } if (stripos($twMsgFormat, '%ANNOUNCE%') !== false) { $pText = nsTrnc(strip_tags(strip_shortcodes($pText)), 140, " ", "..."); $pText = nsTrnc($pText, $twLim); $twMsgFormat = str_ireplace("%ANNOUNCE%", $pText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pText); } if (stripos($twMsgFormat, '%RAWEXCERPT%') !== false) { $exrText = nsTrnc(strip_tags(strip_shortcodes($exrText)), 140, " ", "..."); $exrText = nsTrnc($exrText, $twLim); $twMsgFormat = str_ireplace("%RAWEXCERPT%", $exrText, $twMsgFormat); $twLim = $twLim - nxs_strLen($exrText); } if (stripos($twMsgFormat, '%FULLTEXT%') !== false) { $pFullText = nsTrnc(strip_tags($pFullText), $twLim); $twMsgFormat = str_ireplace("%FULLTEXT%", $pFullText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pFullText); } if (stripos($twMsgFormat, '%RAWTEXT%') !== false) { $pRawText = nsTrnc(strip_tags($pRawText), $twLim); $twMsgFormat = str_ireplace("%RAWTEXT%", $pRawText, $twMsgFormat); $twLim = $twLim - nxs_strLen($pRawText); } $msg = nsFormatMessage($twMsgFormat, $postID, $addParams); } $msg = str_replace('&#039;', "'", $msg); $msg = str_replace(''', "'", $msg); $msg = str_replace('#039;', "'", $msg); $msg = str_replace('#039', "'", $msg); $msg = str_replace('&#8217;', "'", $msg); $msg = str_replace('’', "'", $msg); $msg = str_replace('#8217;', "'", $msg); $msg = str_replace('#8217', "'", $msg); $msg = str_replace('&#8220;', '"', $msg); $msg = str_replace('“', '"', $msg); $msg = str_replace('#8220;', '"', $msg); $msg = str_replace('#8220', "'", $msg); $msg = str_replace('&#8221;', '"', $msg); $msg = str_replace('”', '"', $msg); $msg = str_replace('#8221;', '"', $msg); $msg = str_replace('#8221', "'", $msg); $msg = str_replace('&#8212;', '-', $msg); $msg = str_replace('—', '-', $msg); $msg = str_replace('#8212;', '-', $msg); $msg = str_replace('#8212', "-", $msg); $msg = nxs_decodeEntitiesFull($msg); $message = array('message' => $msg, 'img' => $imgData, 'urlLength' => $nxs_urlLen); $options['twMsgFormat'] = $msg; //## This meta field is created by the indieweb taxonomy plugin - by David Peach $response = get_post_meta($postID, 'response', true); if (!empty($response)) { $reply_url = $response['url']; if (!empty($reply_url) && strpos($reply_url, 'twitter.com')) { $explode_at_domain = explode('twitter.com/', $reply_url); $twitter_path = end($explode_at_domain); $exploded_path = explode('/', $twitter_path); $options['in_reply_to_id'] = end($exploded_path); } } //prr($options); //## Actual Post $ntToPost = new nxs_class_SNAP_TW(); $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); } }
function doPostToGooglePlus2($msg, $lnk = '', $pageID = '') { $rnds = rndString ( 13 ); $pageID = trim ( $pageID ); if (function_exists ( 'nxs_decodeEntitiesFull' )) $msg = nxs_decodeEntitiesFull ( $msg ); if (function_exists ( 'nxs_html_to_utf8' )) $msg = nxs_html_to_utf8 ( $msg ); $msg = str_replace ( '<br>', "_NXSZZNXS_5Cn", $msg ); $msg = str_replace ( '<br/>', "_NXSZZNXS_5Cn", $msg ); $msg = str_replace ( '<br />', "_NXSZZNXS_5Cn", $msg ); $msg = str_replace ( "\r\n", "\n", $msg ); $msg = str_replace ( "\n\r", "\n", $msg ); $msg = str_replace ( "\r", "\n", $msg ); $msg = str_replace ( "\n", "_NXSZZNXS_5Cn", $msg ); $msg = urlencode ( strip_tags ( $msg ) ); $msg = str_replace ( "_NXSZZNXS_5Cn", "%5Cn", $msg ); $msg = str_replace ( '+', '%20', $msg ); $msg = str_replace ( '%0A%0A', '%20', $msg ); $msg = str_replace ( '%0A', '', $msg ); $msg = str_replace ( '%0D', '%5C', $msg ); if (trim ( $lnk ['img'] ) != '') { $img = getCurlPageX ( $lnk ['img'], '', false ); if ($img ['http_code'] == '200') $lnk ['imgType'] = urlencode ( $img ['content_type'] ); else $lnk ['img'] = ''; } $lnk ['img'] = urlencode ( $lnk ['img'] ); $lnk ['link'] = urlencode ( $lnk ['link'] ); $lnk ['fav'] = urlencode ( $lnk ['fav'] ); $lnk ['domain'] = urlencode ( $lnk ['domain'] ); $lnk ['title'] = (str_replace ( Array ( "\n", "\r" ), ' ', $lnk ['title'] )); // $lnk['title'] = mysql_real_escape_string($lnk['title']); $lnk['title'] = mysql_real_escape_string($lnk['title']); $lnk['title'] = mysql_real_escape_string($lnk['title']); $lnk ['title'] = rawurlencode ( addslashes ( $lnk ['title'] ) ); // ## Yes mysql_real_escape_string has to be called 3 times. The message should have 7 escape slashes /. Why G? Why? $lnk ['txt'] = (str_replace ( Array ( "\n", "\r" ), ' ', $lnk ['txt'] )); // $lnk['txt'] = mysql_real_escape_string($lnk['txt']); $lnk['txt'] = mysql_real_escape_string($lnk['txt']); $lnk['txt'] = mysql_real_escape_string($lnk['txt']); $lnk ['txt'] = rawurlencode ( addslashes ( $lnk ['txt'] ) ); // ## Yes mysql_real_escape_string has to be called 3 times. The message should have 7 escape slashes /. Why G? Why? $refPage = 'https://plus.google.com/b/' . $pageID . '/'; // prr($lnk); if ($pageID != '') { // ## Posting to Page $gpp = 'https://plus.google.com/b/' . $pageID . '/_/sharebox/post/?spam=20&_reqid=647379&rt=j'; $contents = getCurlPageX ( $refPage, '', false ); // prr($contents); die(); } else { // ## Posting to Profile $gpp = 'https://plus.google.com/_/sharebox/post/?spam=20&_reqid=1203718&rt=j'; $contents = getCurlPageX ( 'https://plus.google.com/', '', false ); $pageID = CutFromTo ( $contents ['content'], "key: '2'", "]" ); $pageID = CutFromTo ( $pageID, 'https://plus.google.com/', '"' ); } // echo $lnk['txt']; if ($contents ['http_code'] == '400') return "Invalid Sharebox Page. Something is wrong, please contact support"; $at = CutFromTo ( $contents ['content'], 'csi.gstatic.com/csi","', '",' ); // prr($lnk); // ## URL if (trim ( $lnk ['link'] ) != '') $spar = "f.req=%5B%22" . $msg . "%22%2C%22oz%" . $pageID . "." . $rnds . ".0%22%2Cnull%2Cnull%2Cnull%2Cnull%2C%22%5B%5C%22%5Bnull%2Cnull%2Cnull%2C%5C%5C%5C%22" . $lnk ['title'] . "%5C%5C%5C%22%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5Bnull%2C%5C%5C%5C%22NextScripts%5C%5C%5C%22%2C%5C%5C%5C%22owner%5C%5C%5C%22%5D%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5C%5C%5C%22" . str_replace ( '%5C', '%5C%5C%5C%5C%5C%5C%5C', $lnk ['txt'] ) . "%5C%5C%5C%22%2Cnull%2Cnull%2C%5Bnull%2C%5C%5C%5C%22" . $lnk ['link'] . "%5C%5C%5C%22%2Cnull%2C%5C%5C%5C%22text%2Fhtml%5C%5C%5C%22%2C%5C%5C%5C%22document%5C%5C%5C%22%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5Bnull%2C%5C%5C%5C%22" . $lnk ['fav'] . "%5C%5C%5C%22%2Cnull%2Cnull%5D%2C%5Bnull%2C%5C%5C%5C%22" . $lnk ['fav'] . "%5C%5C%5C%22%2Cnull%2Cnull%5D%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5Bnull%2C%5C%5C%5C%22%5C%5C%5C%22%2C%5C%5C%5C%22http%3A%2F%2Fgoogle.com%2Fprofiles%2Fmedia%2Fprovider%5C%5C%5C%22%2C%5C%5C%5C%22%5C%5C%5C%22%5D%5D%5D%5C%22%2C%5C%22%5Bnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5Bnull%2C%5C%5C%5C%22" . $lnk ['img'] . "%5C%5C%5C%22%5D%2Cnull%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5Bnull%2C%5C%5C%5C%22" . $lnk ['link'] . "%5C%5C%5C%22%2Cnull%2C%5C%5C%5C%22" . $lnk ['imgType'] . "%5C%5C%5C%22%2C%5C%5C%5C%22photo%5C%5C%5C%22%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C200%2C150%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5Bnull%2C%5C%5C%5C%22" . $lnk ['img'] . "%5C%5C%5C%22%2Cnull%2Cnull%5D%2C%5Bnull%2C%5C%5C%5C%22" . $lnk ['img'] . "%5C%5C%5C%22%2Cnull%2Cnull%5D%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5Bnull%2C%5C%5C%5C%22images%5C%5C%5C%22%2C%5C%5C%5C%22http%3A%2F%2Fgoogle.com%2Fprofiles%2Fmedia%2Fprovider%5C%5C%5C%22%2C%5C%5C%5C%22%5C%5C%5C%22%5D%5D%5D%5C%22%5D%22%2Cnull%2Cnull%2Ctrue%2C%5B%5D%2Cfalse%2Cfalse%2Cnull%2C%5B%5D%2Cnull%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cfalse%2Cfalse%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5B35%2C1%2C0%5D%2C%22" . $lnk ['link'] . "%22%2Cnull%2C%7B%2229646191%22%3A%5B%22" . $lnk ['link'] . "%22%2C%22" . $lnk ['img'] . "%22%2C%22" . $lnk ['title'] . "%22%2C%22" . $lnk ['txt'] . "%22%2Cnull%2C%5B%22%2F%2Fimages1-focus-opensocial.googleusercontent.com%2Fgadgets%2Fproxy%3Furl%3D" . $lnk ['img'] . "%26container%3Dfocus%26gadget%3Da%26rewriteMime%3Dimage%2F*%26refresh%3D31536000%26resize_h%3D150%26resize_w%3D150%26no_expand%3D1%22%2C150%2C150%5D%2C%22" . $lnk ['fav'] . "%22%2C%5B%5B%5B5%2C0%5D%2Cnull%2Cnull%2C%7B%2227219582%22%3A%5Bnull%2Cnull%2Cnull%2C%22NextScripts%22%5D%7D%5D%5D%5D%7D%5D%2Cnull%2C%5B%5D%2C%5B%5B%5Bnull%2Cnull%2C1%5D%5D%5D%5D&at=" . $at . "&"; // ## Image elseif (trim ( $lnk ['img'] ) != '') { $remImgURL = urldecode ( $lnk ['img'] ); $urlParced = pathinfo ( $remImgURL ); $remImgURLFilename = $urlParced ['basename']; $imgData = getCurlPageX ( $remImgURL, '', false ); $imgdSize = $imgData ['download_content_length']; $imgData = $imgData ['content']; $iflds = '{"protocolVersion":"0.8","createSessionRequest":{"fields":[{"external":{"name":"file","filename":"' . $remImgURLFilename . '","put":{},"size":' . $imgdSize . '}},{"inlined":{"name":"batchid","content":"1350593121640","contentType":"text/plain"}},{"inlined":{"name":"client","content":"sharebox","contentType":"text/plain"}},{"inlined":{"name":"disable_asbe_notification","content":"true","contentType":"text/plain"}},{"inlined":{"name":"streamid","content":"updates","contentType":"text/plain"}},{"inlined":{"name":"use_upload_size_pref","content":"true","contentType":"text/plain"}},{"inlined":{"name":"album_abs_position","content":"0","contentType":"text/plain"}}]}}'; $imgReqCnt = getCurlPageX ( 'https://plus.google.com/_/upload/photos/resumable?authuser=0', '', false, $iflds ); $gUplURL = str_replace ( '\u0026', '&', CutFromTo ( $imgReqCnt ['content'], 'putInfo":{"url":"', '"' ) ); $gUplID = CutFromTo ( $imgReqCnt ['content'], 'upload_id":"', '"' ); $imgUplCnt = getCurlPageX ( $gUplURL, '', true, $imgData ); $imgUplCnt = json_decode ( $imgUplCnt, true ); $infoArray = $imgUplCnt ['sessionStatus'] ['additionalInfo'] ['uploader_service.GoogleRupioAdditionalInfo'] ['completionInfo'] ['customerSpecificInfo']; $albumID = $infoArray ['albumid']; $photoid = $infoArray ['photoid']; $imgUrl = urlencode ( $infoArray ['url'] ); $imgTitie = $infoArray ['title']; $width = $infoArray ['width']; $height = $infoArray ['height']; $userID = $infoArray ['username']; $intID = $infoArray ['albumPageUrl']; $intID = str_replace ( 'https://picasaweb.google.com/', '', $intID ); $intID = str_replace ( $userID, '', $intID ); $intID = str_replace ( '/', '', $intID ); $spar = "f.req=%5B%22" . $msg . "%22%2C%22oz%3A" . $pageID . "." . $rnds . "%22%2Cnull%2C%22" . $albumID . "%22%2Cnull%2Cnull%2C%22%5B%5C%22%5Bnull%2Cnull%2Cnull%2C%5C%5C%5C%22%5C%5C%5C%22%2Cnull%2C%5Bnull%2C%5C%5C%5C%22" . $imgUrl . "%5C%5C%5C%22%2C" . $height . "%2C" . $width . "%5D%2Cnull%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5C%5C%5C%22" . $imgTitie . "%5C%5C%5C%22%2Cnull%2Cnull%2C%5Bnull%2C%5C%5C%5C%22https%3A%2F%2Fpicasaweb.google.com%2F" . $userID . "%2F" . $intID . "%23" . $photoid . "%5C%5C%5C%22%2Cnull%2C%5C%5C%5C%22image%2Fjpeg%5C%5C%5C%22%2C%5C%5C%5C%22image%5C%5C%5C%22%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5Bnull%2C%5C%5C%5C%22" . $imgUrl . "%5C%5C%5C%22%2C120%2C165.51724137931035%5D%2C%5Bnull%2C%5C%5C%5C%22" . $imgUrl . "%5C%5C%5C%22%2C120%2C165.51724137931035%5D%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5Bnull%2C%5C%5C%5C%22picasa%5C%5C%5C%22%2C%5C%5C%5C%22http%3A%2F%2Fgoogle.com%2Fprofiles%2Fmedia%2Fprovider%5C%5C%5C%22%2C%5C%5C%5C%22%5C%5C%5C%22%5D%2C%5Bnull%2C%5C%5C%5C%22albumid%3D" . $albumID . "%26photoid%3D" . $photoid . "%5C%5C%5C%22%2C%5C%5C%5C%22http%3A%2F%2Fgoogle.com%2Fprofiles%2Fmedia%2Fonepick_media_id%5C%5C%5C%22%2C%5C%5C%5C%22%5C%5C%5C%22%5D%5D%5D%5C%22%5D%22%2Cnull%2Cnull%2Ctrue%2C%5B%5D%2Cfalse%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cfalse%2Cnull%2Cnull%2C%22" . $userID . "%22%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cfalse%2Cfalse%2Ctrue%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5B249%2C18%2C1%2C0%5D%2Cnull%2Cnull%2Cnull%2C%7B%2227639957%22%3A%5B%5B%22https%3A%2F%2Fpicasaweb.google.com%2F" . $userID . "%2F" . $intID . "%23" . $photoid . "%22%2C%22" . $imgTitie . "%22%2C%22%22%2C%22" . $imgUrl . "%22%2Cnull%2C%5B%22" . $imgUrl . "%22%2C497%2C373%2Cnull%2Cnull%2Cnull%2Cnull%2C145%2C%5B1%2C%22" . $imgUrl . "%22%5D%5D%2Cnull%2C%22200%22%2C%22" . $height . "%22%2C" . $width . "%2C145%2Cnull%2C%22picasaweb.google.com%22%5D%2C%22" . $userID . "%22%2Cnull%2C%22" . $photoid . "%22%2Cnull%2Cnull%2C%22" . $imgUrl . "%22%2Cnull%2Cnull%2C%22https%3A%2F%2Fpicasaweb.google.com%2F" . $userID . "%2F" . $intID . "%23" . $photoid . "%22%2Cnull%2C%22albumid%3D" . $albumID . "%26photoid%3D" . $photoid . "%22%5D%7D%5D%2Cnull%2C%5B%5D%2C%5B%5B%5Bnull%2Cnull%2C1%5D%5D%2Cnull%5D%5D&at=" . $at . "&"; // echo $spar; } // ## Just Message else $spar = "f.req=%5B%22" . $msg . "%22%2C%22oz%3A" . $pageID . "." . $rnds . "%22%2Cnull%2Cnull%2Cnull%2Cnull%2C%22%5B%5D%22%2Cnull%2C%22%7B%5C%22aclEntries%5C%22%3A%5B%7B%5C%22scope%5C%22%3A%7B%5C%22scopeType%5C%22%3A%5C%22anyone%5C%22%2C%5C%22name%5C%22%3A%5C%22Anyone%5C%22%2C%5C%22id%5C%22%3A%5C%22anyone%5C%22%2C%5C%22me%5C%22%3Atrue%2C%5C%22requiresKey%5C%22%3Afalse%7D%2C%5C%22role%5C%22%3A20%7D%2C%7B%5C%22scope%5C%22%3A%7B%5C%22scopeType%5C%22%3A%5C%22anyone%5C%22%2C%5C%22name%5C%22%3A%5C%22Anyone%5C%22%2C%5C%22id%5C%22%3A%5C%22anyone%5C%22%2C%5C%22me%5C%22%3Atrue%2C%5C%22requiresKey%5C%22%3Afalse%7D%2C%5C%22role%5C%22%3A60%7D%5D%7D%22%2Ctrue%2C%5B%5D%2Cfalse%2Cfalse%2Cnull%2C%5B%5D%2Cnull%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cfalse%2Cfalse%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5D%5D&at=" . $at . "&"; $spar = str_ireplace ( '+', '%20', $spar ); $spar = str_ireplace ( ':', '%3A', $spar ); $contents = getCurlPageX ( $gpp, $refPage, false, $spar ); // prr($contents); if ($contents ['http_code'] == '403') return "Error: You are not authorized to publish to this page"; if ($contents ['http_code'] == '404') return "Error: Page you are posting is not found.<br/><br/> If you have entered your page ID as 117008619877691455570/117008619877691455570, please remove the second copy. It should be one number only - 117008619877691455570"; if ($contents ['http_code'] == '400') return "Error: Something is wrong, please contact support"; if ($contents ['http_code'] == '200') return "OK"; }
function nxs_doPublishToLI($postID, $options) { global $nxs_gCookiesArr; $ntCd = 'LI'; $ntCdL = 'li'; $ntNm = 'LinkedIn'; //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLI', 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:#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(); } // prr($options); if ($postID == '0') { echo "Testing ... <br/><br/>"; $msgT = 'Test Post from ' . $blogTitle; $link = home_url(); $msg = 'Test Post from ' . $blogTitle . " " . $link; $isAttachLI = ''; $title = $blogTitle; } else { $post = get_post($postID); if (!$post) { return; } $liMsgFormat = $options['liMsgFormat']; $msg = nsFormatMessage($liMsgFormat, $postID); $msgT = nsFormatMessage($options['liMsgFormatT'], $postID); $link = get_permalink($postID); $isAttachLI = $options['liAttch']; $title = nsTrnc($post->post_title, 200); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1')); } $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title; $msgT = nsTrnc($msgT, 200); if ($isAttachLI == '1') { $src = nxs_getPostImage($postID); $dsc = trim(apply_filters('the_content', $post->post_excerpt)); if ($dsc == '') { $dsc = apply_filters('the_content', $post->post_content); } $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300); } $msg = nxs_html_to_utf8($msg); $msgT = nxs_html_to_utf8($msgT); if (function_exists("doConnectToLinkedIn") && $options['ulName'] != '' && $options['uPass'] != '') { $auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth !== false) { die($auth); } $to = $options['uPage'] != '' ? $options['uPage'] : 'http://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace(' ', ' ', $msg); $msg = nsTrnc(strip_tags($msg), 700); if ($postID == '0') { $lnk['title'] = get_bloginfo('name'); $lnk['desc'] = get_bloginfo('description'); $lnk['url'] = home_url(); } else { if ($isAttachLI == '1') { $lnk['title'] = nsTrnc(strip_tags($post->post_title), 200); $lnk['postTitle'] = $msgT; $lnk['desc'] = $dsc; $lnk['url'] = get_permalink($postID); $lnk['img'] = $src; } } //prr($msg); $ret = doPostToLinkedIn($msg, $lnk, $to); $liPostID = $options['uPage']; } else { require_once 'apis/liOAuth.php'; $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier']; $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1); $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700); if ($options['grpID'] != '') { try { // prr($msgT); prr($msg); prr($options['grpID']); prr($src); prr($dsc); $purl = get_permalink($postID); prr($purl); if ($isAttachLI == '1') { $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], get_permalink($postID), $src, $dsc); } else { $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']); } $liPostID = 'http://www.linkedin.com/groups?gid=' . $options['grpID']; } catch (Exception $o) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . "Linkedin Status couldn't be updated! - " . print_r($o, true)); $ret = "ERROR:" . print_r($o, true); } } else { try { if ($isAttachLI == '1') { $ret = $linkedin->postShare($msg, nsTrnc($post->post_title, 200), get_permalink($postID), $src, $dsc); } else { $ret = $linkedin->postShare($msg); } } catch (Exception $o) { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . "<br/>Linkedin Status couldn't be updated! - " . print_r($o, true)); $ret = "ERROR:" . print_r($o, true); } } //$liPostID = $linkedin->getCurrentShare(); prr($liPostID); if ($liPostID == '') { $liPostID = $options['liUserInfo']; } } if (stripos($ret, 'update-url') !== false) { $liPostID = CutFromTo($ret, '<update-url>', '</update-url>'); $ret = '201'; } if ($ret != '201') { if ($postID == '0') { prr($ret); } nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($ret, true), $extInfo); } else { if ($postID == '0') { echo 'OK - Linkedin status updated successfully'; nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); } else { nxs_metaMarkAsPosted($postID, 'LI', $options['ii'], array('isPosted' => '1', 'pgID' => $liPostID, 'pDate' => date('Y-m-d H:i:s'))); nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); } } if ($ret == '201') { return true; } else { return 'Something Wrong'; } }
function doPostToNT($options, $message) { $badOut = array('postID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); $liPostID = ''; //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if ((!isset($options['ulName']) || trim($options['uPass']) == '') && empty($options['liOAuthVerifier'])) { $badOut['Error'] = 'Not Configured'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } if (empty($options['liMsgFormatT'])) { $options['liMsgFormatT'] = '%TITLE%'; } //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['liMsgFormat'], $message); } if (!empty($message['pTitle'])) { $msgT = $message['pTitle']; } else { $msgT = nxs_doFormatMsg($options['liMsgFormatT'], $message); } if (empty($options['postType'])) { if ((int) $options['liAttch'] == 1 || $isNew) { $options['postType'] = 'A'; } } if ($options['postType'] == 'A' || $options['postType'] == 'I') { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } if (preg_match("/noImg.\\.png/i", $imgURL)) { $imgURL = ''; } if (!empty($message['urlDescr'])) { $dsc = $message['urlDescr']; } else { $dsc = $msg; } $dsc = strip_tags($dsc); $dsc = nxs_decodeEntitiesFull($dsc); $dsc = nxs_html_to_utf8($dsc); $dsc = nsTrnc($dsc, 300); } $msg = strip_tags($msg); $msg = nxs_html_to_utf8($msg); $msgT = nxs_html_to_utf8($msgT); $urlToGo = $message['url']; if (function_exists("doConnectToLinkedIn") && $options['ulName'] != '' && $options['uPass'] != '') { $dusername = $options['ulName']; $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass']; // ??? Do we need that?????? $auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']); if ($auth != false) { $badOut['Error'] .= "|Auth Error - " . $auth; return $badOut; } $to = $options['uPage'] != '' ? $options['uPage'] : 'https://www.linkedin.com/home'; $lnk = array(); $msg = str_ireplace(' ', ' ', $msg); $msg = nsTrnc(strip_tags($msg), 700); $lnk['postTitle'] = $msgT; if ($options['postType'] == 'A') { $lnk['title'] = $message['urlTitle']; $lnk['desc'] = $message['urlDescr']; $lnk['url'] = $urlToGo; $lnk['img'] = $imgURL; $lnk['postType'] = 'A'; } if ($options['postType'] == 'I') { $lnk['title'] = ''; $lnk['desc'] = ''; $lnk['url'] = $imgURL; $lnk['img'] = $imgURL; $lnk['postType'] = 'I'; $lnk['postTitle'] = $msgT; } if ($options['postType'] == 'T') { $lnk['postType'] = 'T'; } global $nxs_gCookiesArr; $li = new nxsAPI_LI(); $li->debug = false; if (!empty($nxs_gCookiesArr)) { $li->ck = $nxs_gCookiesArr; } $ret = $li->post($msg, $lnk, $to); if (is_array($ret) && !empty($ret['isPosted'])) { return $ret; } $liPostID = $options['uPage']; } else { if (!empty($options['isV2'])) { //## V2 if ($options['grpID'] != '') { try { if ($msgT == '') { $msgT = ' '; } if ($options['postType'] == 'A') { $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID'], str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID']); } $liPostID = 'http://www.linkedin.com/groups?gid=' . $options['grpID']; } catch (Exception $o) { $ret = "ERROR: " . print_r($o, true); } } else { //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc; if ($options['postType'] == 'A') { $ret = $this->postShare($options['liAccessToken'], $msg, nsTrnc($msgT, 200), str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $this->postShare($options['liAccessToken'], $msg); } } } else { //## V1 require_once 'apis/liOAuth.php'; $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']); $linkedin->oauth_verifier = $options['liOAuthVerifier']; $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1); $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1); $msg = nsTrnc($msg, 700); //prr($urlToGo); $urlToGo = urlencode($urlToGo); prr($urlToGo); die(); if ($options['grpID'] != '') { try { if ($msgT == '') { $msgT = ' '; } if ($options['postType'] == 'A') { $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']); } $liPostID = 'http://www.linkedin.com/groups?gid=' . $options['grpID']; if ($ret == '201') { $ret = array('updateUrl' => $liPostID); } } catch (Exception $o) { $ret = "ERROR: " . print_r($o, true); } } else { //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc; try { if ($options['postType'] == 'A') { $ret = $linkedin->postShare($msg, nsTrnc($msgT, 200), str_replace('&', '&', $urlToGo), $imgURL, $dsc); } else { $ret = $linkedin->postShare($msg); } } catch (Exception $o) { $ret = "ERROR:" . print_r($o, true); } } } if ($liPostID == '') { $liPostID = $options['liUserInfo']; } } // prr($ret); if (!is_array($ret) && stripos($ret, '<update-url>') !== false) { $rurl = CutFromTo($ret, '<update-url>', '</update-url>'); $ret = array('updateUrl' => $rurl); } if (is_array($ret) && !empty($ret['updateUrl'])) { if (stripos($ret['updateUrl'], 'topic=') !== false) { $liPostID = CutFromTo($ret['updateUrl'], 'topic=', '&'); } else { $liPostID = ''; } return array('isPosted' => '1', 'postID' => $liPostID, 'postURL' => $ret['updateUrl'], 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= print_r($ret, true); } return $badOut; }
function postShare($msg, $title = '', $url = '', $imgURL = '', $dsc = '') { $status_url = $this->base_url . "/v1/people/~/shares"; $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title)); $xml = '<?xml version="1.0" encoding="UTF-8"?><share><comment>' . htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8") . '</comment>' . ($url != '' ? '<content><title>' . htmlspecialchars($title, ENT_NOQUOTES, "UTF-8") . '</title><submitted-url>' . $url . '</submitted-url>' . (!empty($imgURL) ? '<submitted-image-url>' . $imgURL . '</submitted-image-url>' : '') . '<description>' . htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8") . '</description></content>' : '') . '<visibility><code>anyone</code></visibility></share>'; $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url); $request->sign_request($this->signature_method, $this->consumer, $this->access_token); $auth_header = $request->to_header("https://api.linkedin.com"); //if ($debug) echo $auth_header . "\n"; $response = $this->httpRequest($status_url, $auth_header, "POST", $xml); return $response; }
function post($msg, $imgURL, $lnk, $boardID, $title = '', $price='', $via=''){ $tk = $this->tk; $ck = $this->ck; $apVer = $this->apVer; if ($this->debug) echo "[PN] Posting to ...".$boardID."<br/>\r\n"; foreach ($ck as $c) if ( is_object($c) && $c->name=='csrftoken') $tk = $c->value; $msg = strip_tags($msg); $msg = substr($msg, 0, 480); $tgs = ''; $this->tk = $tk; if ($msg=='') $msg = ' '; if (trim($boardID)=='') return "Board is not Set"; if (trim($imgURL)=='') return "Image is not Set"; $msg = str_ireplace(array("\r\n", "\n", "\r"), " ", $msg); $msg = strip_tags($msg); if (function_exists('nxs_decodeEntitiesFull')) $msg = nxs_decodeEntitiesFull($msg, ENT_QUOTES); $mgsOut = urlencode($msg); $mgsOut = str_ireplace(array('%28', '%29', '%27', '%21', '%22', '%09'), array("(", ")", "'", "!", "%5C%22", '%5Ct'), $mgsOut); $fldsTxt = 'source_url=%2Fpin%2Ffind%2F%3Furl%3D'.urlencode(urlencode($lnk)).'&data=%7B%22options%22%3A%7B%22board_id%22%3A%22'.$boardID.'%22%2C%22description%22%3A%22'.$mgsOut.'%22%2C%22link%22%3A%22'.urlencode($lnk).'%22%2C%22share_twitter%22%3Afalse%2C%22image_url%22%3A%22'.urlencode($imgURL).'%22%2C%22method%22%3A%22scraped%22%7D%2C%22context%22%3A%7B%7D%7D'; $hdrsArr = $this->headers('https://www.pinterest.com/resource/PinResource/create/ ', 'https://www.pinterest.com', 'POST', true); $hdrsArr['X-NEW-APP']='1'; $hdrsArr['X-APP-VERSION']=$apVer; $hdrsArr['X-CSRFToken']=$tk; $hdrsArr['X-Pinterest-AppState']='active'; $hdrsArr['Accept'] = 'application/json, text/javascript, */*; q=0.01'; $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $fldsTxt); $rep = nxs_remote_post('https://www.pinterest.com/resource/PinResource/create/', $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $contents = $rep['body']; $resp = json_decode($contents, true); // prr($advSet); prr($resp); prr($fldsTxt); // prr($contents); if (is_array($resp)) { if (isset($resp['resource_response']) && isset($resp['resource_response']['error']) && $resp['resource_response']['error']!='' ) return print_r($resp['resource_response']['error'], true); elseif (isset($resp['resource_response']) && isset($resp['resource_response']['data']) && $resp['resource_response']['data']['id']!=''){ // gor JSON if (isset($resp['resource_response']) && isset($resp['resource_response']['error']) && $resp['resource_response']['error']!='') return print_r($resp['resource_response']['error'], true); else return array("isPosted"=>"1", "postID"=>$resp['resource_response']['data']['id'], 'pDate'=>date('Y-m-d H:i:s'), "postURL"=>"http://www.pinterest.com/pin/".$resp['resource_response']['data']['id']); } }elseif (stripos($contents, 'blocked this')!==false) { $retText = trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>')))); return "Pinterest ERROR: 'The Source is blocked'. Please see https://support.pinterest.com/entries/21436306-why-is-my-pin-or-site-blocked-for-spam-or-inappropriate-content/ for more info | Pinterest Message:".$retText; } elseif (stripos($contents, 'image you tried to pin is too small')!==false) { $retText = trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>')))); return "Image you tried to pin is too small | Pinterest Message:".$retText; } elseif (stripos($contents, 'CSRF verification failed')!==false) { $retText = trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>')))); return "CSRF verification failed - Please contact NextScripts Support | Pinterest Message:".$retText; } elseif (stripos($contents, 'Oops')!==false && stripos($contents, '<body>')!==false ) return 'Pinterest ERROR MESSAGE : '.trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>')))); else return "Somethig is Wrong - Pinterest Returned Error 502"; }
function postToGroup($msg, $title, $groupID, $url = '', $imgURL = '', $dsc = '') { $status_url = $this->base_url . "/v1/groups/" . $groupID . "/posts"; //$debug = true; $dsc = nxs_decodeEntitiesFull(strip_tags($dsc)); $msg = strip_tags(nxs_decodeEntitiesFull($msg)); $title = nxs_decodeEntitiesFull(strip_tags($title)); $xml = '<?xml version="1.0" encoding="UTF-8"?><post><title>' . htmlspecialchars($title, ENT_NOQUOTES, "UTF-8") . '</title>' . "\n" . '<summary>' . htmlspecialchars($msg, ENT_NOQUOTES, "UTF-8") . '</summary>' . "\n" . ' ' . ($url != '' ? '<content><title>' . htmlspecialchars($title, ENT_NOQUOTES, "UTF-8") . '</title>' . "\n" . '<submitted-url>' . $url . '</submitted-url>' . "\n" . (!empty($imgURL) ? '<submitted-image-url>' . $imgURL . '</submitted-image-url>' : '') . "\n" . '<description>' . htmlspecialchars($dsc, ENT_NOQUOTES, "UTF-8") . '</description></content>' : '') . '</post>'; // prr($xml); $request = nsx_trOAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url); $request->sign_request($this->signature_method, $this->consumer, $this->access_token); $auth_header = $request->to_header("https://api.linkedin.com"); //if ($debug) //echo $auth_header . "\n"; $response = $this->httpRequest($status_url, $auth_header, "POST", $xml); //prr($response); return $response; }
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); } }
function postGP($msg, $lnk='', $pageID='', $commPageID='', $commPageCatID=''){ $rnds = rndString(13); $sslverify = false; $ck = $this->ck; $hdrsArr = $this->headers(''); $pageID = trim($pageID); $commPageID = trim($commPageID); $ownerID = ''; $bigCode = ''; $isPostToPage = $pageID!=''; $isPostToComm = $commPageID!=''; if (function_exists('nxs_decodeEntitiesFull')) $msg = nxs_decodeEntitiesFull($msg); if (function_exists('nxs_html_to_utf8')) $msg = nxs_html_to_utf8($msg); $msg = str_replace('<br>', "_NXSZZNXS_5Cn", $msg); $msg = str_replace('<br/>', "_NXSZZNXS_5Cn", $msg); $msg = str_replace('<br />', "_NXSZZNXS_5Cn", $msg); $msg = str_replace("\r\n", "\n", $msg); $msg = str_replace("\n\r", "\n", $msg); $msg = str_replace("\r", "\n", $msg); $msg = str_replace("\n", "_NXSZZNXS_5Cn", $msg); $msg = str_replace('"', '\"', $msg); $msg = urlencode(strip_tags($msg)); $msg = str_replace("_NXSZZNXS_5Cn", "%5Cn", $msg); $msg = str_replace('+', '%20', $msg); $msg = str_replace('%0A%0A', '%20', $msg); $msg = str_replace('%0A', '', $msg); $msg = str_replace('%0D', '%5C', $msg); if (!empty($lnk) && !is_array($lnk)) $lnk = $this->urlInfo($lnk); if ($lnk=='') $lnk = array('img'=>'', 'link'=>'', 'fav'=>'', 'domain'=>'', 'title'=>'', 'txt'=>''); if (!isset($lnk['link']) && !empty($lnk['img'])) { $hdrsArr = $this->headers(''); unset($hdrsArr['Connection']); $rep = nxs_remote_get($lnk['img'], array('headers' => $hdrsArr, 'httpversion' => '1.1', 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) $lnk['img']=''; elseif ($rep['response']['code']=='200' && !empty($rep['headers']['content-type']) && stripos($rep['headers']['content-type'],'text/html')===false) { if (!empty($rep['headers']['content-length'])) $imgdSize = $rep['headers']['content-length']; if ((empty($imgdSize) || $imgdSize == '-1') && !empty($rep['headers']['size_download'])) $imgdSize = $rep['headers']['size_download']; if ((empty($imgdSize) || $imgdSize == '-1')){ $ch = curl_init($lnk['img']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_NOBODY, TRUE); $data = curl_exec($ch); $imgdSize = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); curl_close($ch); } if ((empty($imgdSize) || $imgdSize == '-1')) $imgdSize = strlen($rep['body']); $urlParced = pathinfo($lnk['img']); $remImgURL = $lnk['img']; $remImgURLFilename = nxs_mkImgNm(nxs_clFN($urlParced['basename']), $rep['headers']['content-type']); $imgData = $rep['body']; } else $lnk['img']=''; } if (isset($lnk['img'])) $lnk['img'] = urlencode($lnk['img']); if (isset($lnk['link'])) $lnk['link'] = urlencode($lnk['link']); if (isset($lnk['fav'])) $lnk['fav'] = urlencode($lnk['fav']); if (isset($lnk['domain'])) $lnk['domain'] = urlencode($lnk['domain']); if (isset($lnk['title'])) { $lnk['title'] = (str_replace(Array("\n", "\r"), ' ', $lnk['title'])); $lnk['title'] = rawurlencode(addslashes($lnk['title'])); } if (isset($lnk['txt'])) { $lnk['txt'] = (str_replace(Array("\n", "\r"), ' ', $lnk['txt'])); $lnk['txt'] = rawurlencode( addslashes($lnk['txt'])); } $refPage = 'https://plus.google.com/b/'.$pageID.'/'; $rndReqID = rand(1203718, 647379); $rndSpamID = rand(4, 52); if ($commPageID!='') { //## Posting to Community if ($pageID!='') $pgIDT = 'u/0/b/'.$pageID.'/'; else $pgIDT = ''; $gpp = 'https://plus.google.com/'.$pgIDT.'_/sharebox/post/?spam='.$rndSpamID.'&_reqid='.$rndReqID.'&rt=j'; $rep = nxs_remote_get('https://plus.google.com/communities/'.$commPageID, array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck, 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR commPageID"; return $badOut; } /* if (!empty($rep['cookies'])) $ck = $rep['cookies']; */ $contents = $rep['body']; if (trim($commPageCatID)!='') $commPageID2 = $commPageCatID; else {$commPageID2 = CutFromTo($contents, "AF_initDataCallback({key: '60',", '</script>'); $commPageID2 = CutFromTo($commPageID2, ',,[[["', '"'); } } elseif ($pageID!='') { //## Posting to Page $gpp = 'https://plus.google.com/b/'.$pageID.'/_/sharebox/post/?spam='.$rndSpamID.'&_reqid='.$rndReqID.'&rt=j'; $rep = nxs_remote_get($refPage, array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck, 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR pageID"; return $badOut; } /* if (!empty($rep['cookies'])) $ck = $rep['cookies']; */ $contents = $rep['body']; } else { //## Posting to Profile $gpp = 'https://plus.google.com/u/0/_/sharebox/post/?spam='.$rndSpamID.'&soc-app=1&cid=0&soc-platform=1&hl=en&rt=j'; $rep = nxs_remote_get('https://plus.google.com/', array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck, 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR Main Page"; return $badOut; } /* if (!empty($rep['cookies'])) $ck = $rep['cookies']; */ $contents = $rep['body']; $pageID = CutFromTo($contents, "key: '2'", "]"); /* $pageID = CutFromTo($pageID, 'https://plus.google.com/', '"'); */ $pageID = CutFromTo($pageID, 'data:["', '"'); $refPage = 'https://plus.google.com/'; $refPage = 'https://plus.google.com/_/scs/apps-static/_/js/k=oz.home.en.JYkOx2--Oes.O'; //unset($nxs_gCookiesArr['GAPS']); unset($nxs_gCookiesArr['GALX']); unset($nxs_gCookiesArr['RMME']); unset($nxs_gCookiesArr['LSID']); // We migh still need it ????? } // echo $lnk['txt']; if ($rep['response']['code']=='400') return "Invalid Sharebox Page. Something is wrong, please contact support"; if (stripos($contents,'csi.gstatic.com/csi","')!==false) $at = CutFromTo($contents, 'csi.gstatic.com/csi","', '",'); else { $rep = nxs_remote_get('https://plus.google.com/', array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck, 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR CSI"; return $badOut; } /* if (!empty($rep['cookies'])) $ck = $rep['cookies']; */ $contents = $rep['body']; // prr($rep); if (stripos($contents,'csi.gstatic.com/csi","')!==false) $at = CutFromTo($contents, 'csi.gstatic.com/csi","', '",'); else return "Error (NXS): Lost Login info. Please contact support"; } // prr($lnk); //## URL if (!isset($lnk['txt'])) $lnk['txt'] = ''; $txttxt = $lnk['txt']; $txtStxt = str_replace('%5C', '%5C%5C%5C%5C%5C%5C%5C', $lnk['txt']); if ($isPostToComm) $proOrCommTxt = "%5B%22".$commPageID."%22%2C%22".$commPageID2."%22%5D%5D%2C%5B%5B%5Bnull%2Cnull%2Cnull%2C%5B%22".$commPageID."%22%5D%5D%5D"; else $proOrCommTxt = "%5D%2C%5B%5B%5Bnull%2Cnull%2C1%5D%5D%2Cnull"; if (!empty($lnk['link']) && isset($lnk['arr']) ) { $urlInfo = urlencode(str_replace('\/', '/', str_replace('##-KXKZK-##', '\""', str_replace('""', 'null', str_replace('\""', '##-KXKZK-##', json_encode($lnk['arr'])))))); $urlInfo = str_replace('ZZZZIYYYIZZZ', '',$urlInfo); $spar="f.req=%5B%22".$msg."%22%2C%22oz%3A".$pageID.".".$rnds.".0%22%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Ctrue%2C%5B%5D%2Cfalse%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cfalse%2Cfalse%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2C".$urlInfo."%2Cnull%2C%5B".$proOrCommTxt."%5D%2Cnull%2Cnull%2C2%2Cnull%2Cnull%2Cnull%2C%22!".$bigCode."%22%2Cnull%2Cnull%2Cnull%2C%5B%5D%2C%5B%5Btrue%5D%5D%2Cnull%2C%5B%5D%5D&at=".$at."&"; } //## Video - was here, but now video works like link. So link could be used. //## Image elseif(!empty($lnk['img']) && !empty($imgData)) { $pgAddFlds = ''; //if($isPostToPage) $pgAddFlds = '{"inlined":{"name":"effective_id","content":"'.$pageID.'","contentType":"text/plain"}},{"inlined":{"name":"owner_name","content":"'.$pageID.'","contentType":"text/plain"}},'; else $pgAddFlds = ''; if ($isPostToComm) $proOrCommTxt = "%5B%22".$commPageID."%22%2C%22".$commPageID2."%22%5D%5D%2C%5B%5B%5Bnull%2Cnull%2Cnull%2C%5B%22".$commPageID."%22%5D%5D%5D"; else $proOrCommTxt = "%5D%2C%5B%5B%5Bnull%2Cnull%2C1%5D%5D%2Cnull"; //if (!$isPostToComm) $pgAddFlds = '{"inlined":{"name":"effective_id","content":"'.$pageID.'","contentType":"text/plain"}},{"inlined":{"name":"owner_name","content":"'.$pageID.'","contentType":"text/plain"}},'; else $pgAddFlds = ''; $iflds = '{"protocolVersion":"0.8","createSessionRequest":{"fields":[{"external":{"name":"file","filename":"'.$remImgURLFilename.'","put":{},"size":'.$imgdSize.'}},{"inlined":{"name":"use_upload_size_pref","content":"true","contentType":"text/plain"}},{"inlined":{"name":"batchid","content":"1389803229361","contentType":"text/plain"}},{"inlined":{"name":"client","content":"sharebox","contentType":"text/plain"}},{"inlined":{"name":"disable_asbe_notification","content":"true","contentType":"text/plain"}},{"inlined":{"name":"album_mode","content":"temporary","contentType":"text/plain"}},'.$pgAddFlds.'{"inlined":{"name":"album_abs_position","content":"0","contentType":"text/plain"}}]}}'; $hdrsArr = $this->headers('', 'https://plus.google.com', 'POST', true); $hdrsArr['X-GUploader-Client-Info']='mechanism=scotty xhr resumable; clientVersion=58505203'; $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $iflds, 'sslverify'=>$sslverify);// prr($advSet); $imgReqCnt = nxs_remote_post('https://plus.google.com/_/upload/photos/resumable?authuser=0', $advSet); if (is_nxs_error($imgReqCnt)) { $badOut = print_r($imgReqCnt, true)." - ERROR IMG"; return $badOut; } //prr($imgReqCnt); $gUplURL = str_replace('\u0026', '&', CutFromTo($imgReqCnt['body'], 'putInfo":{"url":"', '"')); $gUplID = CutFromTo($imgReqCnt['body'], 'upload_id":"', '"'); $hdrsArr = $this->headers('', 'https://plus.google.com', 'PUT', true); $hdrsArr['X-GUploader-No-308']='yes'; $hdrsArr['X-HTTP-Method-Override']='PUT'; $hdrsArr['Expect']=''; $hdrsArr['Content-Type']='application/octet-stream'; $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $imgData, 'sslverify'=>$sslverify);// prr($advSet); $imgUplCnt = nxs_remote_post($gUplURL, $advSet); if (is_nxs_error($imgUplCnt)) { $badOut = print_r($imgUplCnt, true)." - ERROR IMG Upl (Upl URL: ".$gUplURL.", IMG URL: ".urldecode($lnk['img']).", FileName: ".$remImgURLFilename.", FIlesize: ".$imgdSize.")"; return $badOut; } $imgUplCnt = json_decode($imgUplCnt['body'], true); if (empty($imgUplCnt)) return "Can't upload image: ".$remImgURL; if (is_array($imgUplCnt) && isset($imgUplCnt['errorMessage']) && is_array($imgUplCnt['errorMessage']) ) return "Error (500): ".print_r($imgUplCnt['errorMessage'], true); $infoArray = $imgUplCnt['sessionStatus']['additionalInfo']['uploader_service.GoogleRupioAdditionalInfo']['completionInfo']['customerSpecificInfo']; $albumID = $infoArray['albumid']; $photoid = $infoArray['photoid']; // $albumID = "5969185467353784753"; $imgUrl = urlencode($infoArray['url']); $imgTitie = $infoArray['title']; $imgUrlX = str_ireplace('https:', '', $infoArray['url']); $imgUrlX = str_ireplace('//lh4.', '//lh3.', $imgUrlX); $imgUrlX = urlencode(str_ireplace('http:', '', $imgUrlX)); $width = $infoArray['width']; $height = $infoArray['height']; $userID = $infoArray['username']; $intID = $infoArray['albumPageUrl']; $intID = str_replace('https://picasaweb.google.com/','', $intID); $intID = str_replace($userID,'', $intID); $intID = str_replace('/','', $intID); // prr($infoArray); $spar="f.req=%5B%22".$msg."%22%2C%22oz%3A".$pageID.".".$rnds.".4%22%2Cnull%2Cnull%2Cnull%2Cnull%2C%22%5B%5D%22%2Cnull%2Cnull%2Ctrue%2C%5B%5D%2Cfalse%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cfalse%2Cfalse%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5B344%2C339%2C338%2C336%2C335%5D%2Cnull%2Cnull%2Cnull%2C%5B%7B%2239387941%22%3A%5Btrue%2Cfalse%5D%7D%5D%2Cnull%2Cnull%2C%7B%2240655821%22%3A%5B%22https%3A%2F%2Fplus.google.com%2Fphotos%2F".$userID."%2Falbums%2F".$albumID."%2F".$photoid."%22%2C%22".$imgUrlX."%22%2C%22".$imgTitie."%22%2C%22%22%2Cnull%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%22".$width."%22%2C%22".$height."%22%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%22".$userID."%22%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%22".$albumID."%22%2C%22".$photoid."%22%2C%22albumid%3D".$albumID."%26photoid%3D".$photoid."%22%2C1%2C%5B%5D%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B%5D%5D%7D%5D%2Cnull%2C%5B".$proOrCommTxt."%5D%2Cnull%2Cnull%2C2%2Cnull%2Cnull%2Cnull%2C%22!".$bigCode."%22%2Cnull%2Cnull%2Cnull%2C%5B%22updates%22%5D%2C%5B%5Btrue%5D%5D%2Cnull%2C%5B%5D%5D&at=".$at."&"; } //## Just Message else $spar="f.req=%5B%22".$msg."%22%2C%22oz%3A".$pageID.".".$rnds.".6%22%2Cnull%2Cnull%2Cnull%2Cnull%2C%22%5B%5D%22%2Cnull%2Cnull%2Ctrue%2C%5B%5D%2Cfalse%2Cnull%2Cnull%2C%5B%5D%2Cnull%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cfalse%2Cfalse%2Cfalse%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2Cnull%2C%5B".$proOrCommTxt."%5D%2Cnull%2Cnull%2C2%2Cnull%2Cnull%2Cnull%2C%22!".$bigCode."%22%2Cnull%2Cnull%2Cnull%2C%5B%5D%2C%5B%5Btrue%5D%5D%2Cnull%2C%5B%5D%5D&at=".$at."&"; //## POST prr(urldecode($spar)); $spar = str_ireplace('+','%20',$spar); $spar = str_ireplace(':','%3A',$spar); $hdrsArr = $this->headers($refPage, 'https://plus.google.com', 'POST', true); $hdrsArr['X-Same-Domain']='1'; //$ckt = $ck; $ck = array(); $no = array("LSID", "ACCOUNT_CHOOSER", "GoogleAccountsLocale_session", "GAPS", "GALX"); foreach ($ckt as $c) {if (!in_array($c->name, $no)) $ck[]=$c;} $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $spar, 'sslverify'=>$sslverify); $rep = nxs_remote_post($gpp, $advSet); if (is_nxs_error($rep)) { $badOut = print_r($rep, true)." - ERROR POST"; return $badOut; } $contents = $rep['body']; // prr($advSet); prr($rep); if ($rep['response']['code']=='403') return "Error: You are not authorized to publish to this page. Are you sure this is even a page? (".$pageID.")"; if ($rep['response']['code']=='404') return "Error: Page you are posting is not found.<br/><br/> If you have entered your page ID as 117008619877691455570/117008619877691455570, please remove the second copy. It should be one number only - 117008619877691455570"; if ($rep['response']['code']=='400') return "Error (400): Something is wrong, please contact support"; if ($rep['response']['code']=='500') return "Error (500): Something is wrong, please contact support"; if ($rep['response']['code']=='200') { $ret = $rep['body']; $remTxt = CutFromTo($ret,'"{\"','}"'); $ret = str_replace($remTxt, '', $ret); $ret = prcGSON($ret); $ret = json_decode($ret, true); if (!empty($ret[0][1][1]) && is_array($ret[0][1][1]) && !empty($ret[0][1][1][0][0][21])) $ret = $ret[0][1][1][0][0][21]; elseif (!empty($ret[0][0][1]) && is_array($ret[0][0][1]) && !empty($ret[0][0][1][0][0][21])) $ret = $ret[0][0][1][0][0][21]; return array('isPosted'=>'1', 'postID'=>$ret, 'postURL'=>'https://plus.google.com/'.$ret, 'pDate'=>date('Y-m-d H:i:s')); } return print_r($contents, true); }