function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['ffUName']) || trim($options['ffPass']) == '') { $badOut['Error'] = 'Not Configured'; return $badOut; } $dusername = $options['ffUName']; $pass = substr($options['ffPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['ffPass'], 5)) : $options['ffPass']; if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['ffMsgFormat'], $message); } if ($options['attchImg'] == '1') { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } } else { $imgURL = ''; } $postArr = array('title' => $msg, 'image0_link' => '', 'room' => $options['grpID'] != '' ? strtolower($options['grpID']) : '', 'image0_url' => $imgURL != '' ? $imgURL : ''); $apicall = "http://friendfeed.com/api/share"; $hdrsArr = $this->nxs_getFFHeaders($dusername . ':' . $pass); $paramcall = array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body' => $postArr, 'headers' => $hdrsArr); $cnt = wp_remote_post($apicall, $paramcall); // prr(json_decode($cnt['body'], true)); if (is_wp_error($cnt)) { $ret = 'Something went wrong - ' . print_r($cnt, true); } else { if (is_array($cnt)) { $retInfo = json_decode($cnt['body'], true); } else { $retInfo = false; } if (is_array($cnt) && $cnt['response']['code'] == '200' && is_array($retInfo)) { return array('postID' => $retInfo['entries'][0]['id'], 'isPosted' => 1, 'postURL' => 'http://friendfeed.com/e/' . $retInfo['entries'][0]['id'], 'pDate' => date('Y-m-d H:i:s')); } else { $ret = "Error: "; if ($cnt['response']['code'] == '401') { $ret .= " Incorrect Username/Password "; } $ret .= $cnt['response']['message']; } } $badOut['Error'] .= $ret; return $badOut; }
function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['wpUName']) || trim($options['wpPass']) == '') { $badOut['Error'] = 'Not Configured'; return $badOut; } $pass = substr($options['wpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['wpPass'], 5)) : $options['wpPass']; if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['wpMsgFormat'], $message); } if (!empty($message['pTitle'])) { $msgT = $message['pTitle']; } else { $msgT = nxs_doFormatMsg($options['wpMsgTFormat'], $message); } if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } $link = urlencode($message['url']); $ext = substr($msg, 0, 1000); //## Fix missing xmlrpc.php if (substr($options['wpURL'], -1) == '/') { $options['wpURL'] = substr($options['wpURL'], 0, -1); } if (substr($options['wpURL'], -10) != 'xmlrpc.php') { $options['wpURL'] .= "/xmlrpc.php"; } //## Post require_once 'apis/xmlrpc-client.php'; $nxsToWPclient = new NXS_XMLRPC_Client($options['wpURL']); $nxsToWPclient->debug = false; if ($imgURL !== '' && stripos($imgURL, 'http') !== false) { // $handle = fopen($imgURL, "rb"); $filedata = ''; while (!feof($handle)) {$filedata .= fread($handle, 8192);} fclose($handle); $filedata = wp_remote_get($imgURL); if (!is_wp_error($filedata)) { $filedata = $filedata['body']; } // echo "AWC?"; $data = array('name' => 'image-' . $message['orID'] . '.jpg', 'type' => 'image/jpg', 'bits' => new NXS_XMLRPC_Base64($filedata), true); $status = $nxsToWPclient->query('metaWeblog.newMediaObject', $message['orID'], $options['wpUName'], $pass, $data); $imgResp = $nxsToWPclient->getResponse(); $gid = $imgResp['id']; } else { $gid = ''; } $params = array(0, $options['wpUName'], $pass, array('software_version')); if (!$nxsToWPclient->query('wp.getOptions', $params)) { $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage(); } else { $ret = 'OK'; } $rwpOpt = $nxsToWPclient->getResponse(); if (!empty($rwpOpt['software_version'])) { $rwpOpt = $rwpOpt['software_version']['value']; $rwpOpt = floatval($rwpOpt); } else { $rwpOpt = 0; } //prr($rwpOpt);prr($nxsToWPclient); //## MAIN Post if ($rwpOpt == 0) { $errMsg = $nxsToWPclient->getErrorMessage(); if ($errMsg != '') { $ret = $errMsg; } else { $ret = 'XMLRPC is not found or not active. WP admin - Settings - Writing - Enable XML-RPC'; } } else { if ($rwpOpt < 3.0) { $ret = 'XMLRPC is too OLD - ' . $rwpOpt . ' You need at least 3.0'; } else { if ($rwpOpt > 3.3) { $nxsToWPContent = array('title' => $msgT, 'description' => $msg, 'post_status' => 'draft', 'mt_excerpt' => $ext, 'mt_allow_comments' => 1, 'mt_allow_pings' => 1, 'post_type' => 'post', 'mt_keywords' => $message['tags'], 'categories' => $message['cats'], 'custom_fields' => ''); $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true); if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage(); } else { $ret = 'OK'; } $pid = $nxsToWPclient->getResponse(); if ($gid != '') { $nxsToWPContent = array('post_thumbnail' => $gid); $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true); if (!$nxsToWPclient->query('wp.editPost', $params)) { $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage(); } else { $ret = 'OK'; } } $nxsToWPContent = array('post_status' => 'publish'); $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true); if (!$nxsToWPclient->query('wp.editPost', $params)) { $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage(); } else { $ret = 'OK'; } } else { $nxsToWPContent = array('title' => $msgT, 'description' => $msg, 'post_status' => 'publish', 'mt_allow_comments' => 1, 'mt_allow_pings' => 1, 'post_type' => 'post', 'mt_keywords' => $message['tags'], 'categories' => $message['cats'], 'custom_fields' => ''); $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true); if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) { $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage(); } else { $ret = 'OK'; } $pid = $nxsToWPclient->getResponse(); } } } if ($ret != 'OK') { $badOut['Error'] .= '-=ERROR=- ' . print_r($ret, true); } else { $wpURL = str_ireplace('/xmlrpc.php', '', $options['wpURL']); if (substr($wpURL, -1) == '/') { $wpURL = substr($wpURL, 0, -1); } $wpURL .= '/?p=' . $pid; return array('postID' => $pid, 'isPosted' => 1, 'postURL' => $wpURL, 'pDate' => date('Y-m-d H:i:s')); } return $badOut; }
function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['pkConsKey']) || trim($options['pkConsSec']) == '' || empty($options['pkAccessTocken'])) { $badOut['Error'] = 'Not Configured'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['pkMsgFormat'], $message); } //## Post require_once 'apis/plurkOAuth.php'; $consumer_key = $options['pkConsKey']; $consumer_secret = $options['pkConsSec']; $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkAccessTocken'], $options['pkAccessTockenSec']); $pkURL = trim(str_ireplace('http://', '', $options['pkURL'])); if (substr($pkURL, -1) == '/') { $pkURL = substr($pkURL, 0, -1); } if ($options['pkCat'] == '') { $options['pkCat'] = ':'; } if ($options['attchImg'] == '1') { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } if ($imgURL != '') { $msg .= " " . $imgURL; } } $postArr = array('content' => $msg, 'qualifier' => $options['pkCat']); $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo); if (is_array($postinfo) && isset($postinfo['plurk_id'])) { $pkID = $postinfo['plurk_id']; } $code = $tum_oauth->http_code; // echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|===="); if ($code == 200 && $pkID != '') { $alphabet = str_split("0123456789abcdefghijklmnopqrstuvwxyz"); $shorten = ''; $plurk_id = $pkID; while ($plurk_id != 0) { $i = $plurk_id % 36; $plurk_id = intval($plurk_id / 36); $shorten = $alphabet[$i] . $shorten; } $link = 'http://www.plurk.com/p/' . $shorten; return array('postID' => $pkID, 'isPosted' => 1, 'postURL' => $link, 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= " ERROR: - " . $postinfo['error_text']; } return $badOut; }
function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['uPass']) || trim($options['uPass']) == '') { $badOut['Error'] = 'Not Authorized'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format Post if (!empty($message['pText'])) { $text = $message['pText']; } else { $text = nxs_doFormatMsg($options['msgFrmt'], $message); } if (!empty($message['pTitle'])) { $msgT = $message['pTitle']; } else { $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message); } //## Make Post if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } //## Make Post if (!empty($options['ck'])) { $ck = maybe_unserialize($options['ck']); } $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass']; $nt = new nxsAPI_ST(); $nt->debug = false; if (!empty($ck)) { $nt->ck = $ck; } $loginErr = $nt->connect($options['uName'], $pass); if (!$loginErr) { $post = array('url' => $message['url'], 'toURL' => $options['mgzURL'], 'imgURL' => $imgURL, 'title' => $msgT, 'text' => $text); $ret = $nt->post($post); if (is_array($ret)) { $ret['ck'] = $nt->ck; return $ret; } else { return print_r($ret, true); } } else { return print_r($loginErr, true); } }
function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['accessToken']) || trim($options['accessToken']) == '') { $badOut['Error'] = 'Not Authorized'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format Post if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['msgFrmt'], $message); } //## Make Post if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } $postType = $options['postType']; require_once 'apis/scOAuth.php'; $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']); $tum_oauth->baseURL = 'https://api.xing.com'; $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); if ($postType == 'A') { $postArr = array('uri' => urlencode($message['url']), 'text' => nsTrnc($msg, 420)); $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/me/share/link', $postArr, 'POST'); } else { $postArr = array('message' => nsTrnc($msg, 420), 'id' => $options['appAppUserID']); $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/' . $options['appAppUserID'] . '/status_message', $postArr, 'POST'); // prr($postinfo); } $code = $tum_oauth->http_code; if ($code == '201') { if (!empty($postinfo) && is_array($postinfo) && !empty($postinfo['ids']) && !empty($postinfo['ids'][0])) { $apNewPostID = $postinfo['ids'][0]; } $np = explode('_', $apNewPostID); $apNewPostURL = 'https://www.xing.com/feedy/stories/' . $np[0]; } else { $apNewPostID = ''; $apNewPostURL = 'https://www.xing.com/profile/' . $options['appPGUserName'] . '/activities'; } if (!empty($apNewPostID) || $code == '201') { return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= print_r($postinfo, true) . " Code:" . $tum_oauth->http_code; return $badOut; } return $badOut; }
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 doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); $lnk = ''; //## Check API Lib // if (!function_exists('doPostToGooglePlus')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php'); if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; } //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['gpUName']) || trim($options['gpPass']) == '') { $badOut['Error'] = 'Not Configured'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Make Post $gpPostType = $options['postType']; if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); } // Make "message default" if ($gpPostType == 'I' || $gpPostType == 'A') { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } } $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['gpPass'], 5)) : $options['gpPass']; $loginError = doConnectToGooglePlus2($email, $pass); if ($loginError !== false) { $badOut['Error'] = print_r($loginError, true) . " - BAD USER/PASS"; return $badOut; } if ($gpPostType == 'I') { $lnk = array(); } if ($gpPostType == 'A') { $lnk = doGetGoogleUrlInfo2($message['url']); } if (is_array($lnk) && $imgURL != '') { $lnk['img'] = $imgURL; } if (is_array($lnk) && $imgURL == '' && $message['noImg'] === true) { $lnk['img'] = ''; } // prr($lnk); prr($message); die(); if ($gpPostType == 'I' && !empty($message['videoURL'])) { $lnk['video'] = $message['videoURL']; } if (!empty($options['gpPageID']) && empty($options['gpCommID'])) { $to = $options['gpPageID']; $ret = doPostToGooglePlus2($msg, $lnk, $to); } elseif (!empty($options['gpCommID'])) { $ret = doPostToGooglePlus2($msg, $lnk, $options['gpPageID'], $options['gpCommID'], $options['gpCCat']); } else { $ret = doPostToGooglePlus2($msg, $lnk); } if (!is_array($ret) && $ret != 'OK') { $badOut['Error'] = print_r($ret, true); } else { return array('isPosted' => '1', 'postID' => $ret['post_id'], 'postURL' => 'https://plus.google.com/' . $ret['post_id'], 'pDate' => date('Y-m-d H:i:s')); } return $badOut; }
function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); $lnk = ''; //## Check API Lib // if (!function_exists('doPostToGooglePlus')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php'); if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; } //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['gpUName']) || trim($options['gpPass']) == '') { $badOut['Error'] = 'Not Configured'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Make Post $gpPostType = $options['postType']; if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); } // Make "message default" if ($gpPostType == 'I' || $gpPostType == 'A') { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } } $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['gpPass'], 5)) : $options['gpPass']; $nt = new nxsAPI_GP(); if (!empty($options['ck'])) { $nt->ck = $options['ck']; } $nt->debug = false; $loginError = $nt->connect($email, $pass); if (!$loginError) { if ($gpPostType == 'A') { $lnk = $message['url']; } elseif ($gpPostType == 'I') { $lnk = array(); if ($imgURL != '') { $lnk['img'] = $imgURL; } if ($imgURL == '' && $message['noImg'] === true) { $lnk['img'] = ''; } if (!empty($message['videoURL'])) { $lnk['video'] = $message['videoURL']; } } $pageID = ''; $comPgID = ''; $comPGCatID = ''; //if (!empty($options['gpPageID']) && empty($options['gpCommID'])) $pageID = $options['gpPageID']; if (!empty($options['gpPageID'])) { $pageID = $options['gpPageID']; } if (!empty($options['gpCommID'])) { $comPgID = $options['gpCommID']; $comPGCatID = $options['gpCCat']; } $result = $nt->postGP($msg, $lnk, $pageID, $comPgID, $comPGCatID); } else { $badOut['Error'] = "Login/Connection Error: " . print_r($loginError, true); return $badOut; } if (is_array($result) && $result['isPosted'] == '1') { nxs_save_glbNtwrks('gp', $options['ii'], $nt->ck, 'ck'); } return $result; }
function doPostToNT($options, $message) { $badOut = array('Warning' => '', 'Error' => ''); $wprg = array('sslverify' => false); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (empty($options['fbAppAuthToken']) && empty($options['atpKey']) && empty($options['uName'])) { $badOut['Error'] = 'No Auth Token Found/Not configured'; return $badOut; } //## Make Post // $facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true )); if (!empty($options['fbAppAuthToken'])) { if (!isset($options['fbAppPageAuthToken']) || trim($options['fbAppPageAuthToken']) == '') { $options['fbAppPageAuthToken'] = $options['fbAppAuthToken']; } } //## Some OLD Format Conversion if (!isset($options['attachType']) && isset($options['fbAttch'])) { $options['attachType'] = $options['fbAttch']; } if (!isset($options['postType']) && isset($options['fbPostType'])) { $options['postType'] = $options['fbPostType']; } $fbPostType = $options['postType']; //## Compatibility with v <3.2 if (!isset($options['pgID']) && isset($options['fbPgID'])) { $options['pgID'] = $options['fbPgID']; } if ($fbPostType != 'I' && $fbPostType != 'T') { $url = $message['url']; $flds = array('id' => $url, 'scrape' => 'true'); sleep(2); } //## Get URL info. if ($fbPostType != 'I' && $fbPostType != 'T' && !empty($options['atchUse']) && $options['atchUse'] == 'F') { $response = wp_remote_post('http://graph.facebook.com', array('body' => $flds, 'sslverify' => false)); if (is_wp_error($response)) { $badOut['Error'] = print_r($response, true) . " - ERROR"; } else { $response = json_decode($response['body'], true); // prr($response); die(); if (!empty($response['description'])) { $message['urlDescr'] = $response['description']; } if (!empty($response['title'])) { $message['urlTitle'] = $response['title']; } if (!empty($response['site_name'])) { $message['siteName'] = $response['site_name']; } elseif ($message['siteName'] == '') { $message['siteName'] = $message['title']; } if (!empty($response['image'][0]['url'])) { $message['imageURL'] = $response['image'][0]['url']; } } } // prr($message); if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['fbMsgFormat'], $message); } $imgURL = nxs_getImgfrOpt($message['imageURL']); $fbWhere = 'feed'; $attachType = $options['attachType']; if ($attachType == '1') { $attachType = 'A'; } else { $attachType = 'S'; } if ($options['imgUpl'] != '2') { $options['imgUpl'] = 'T'; } else { $options['imgUpl'] = 'A'; } if (stripos($options['fbURL'], '/groups/') != false) { $options['destType'] == 'gr'; } if (!empty($options['destType']) && $options['destType'] == 'pr') { $page_id = $options['fbAppAuthUser']; } else { $page_id = $options['pgID']; } $msg = strip_tags($msg); $msg = str_ireplace('<(")', '<(")', $msg); //## FB Smiles FIX 3 if (substr($msg, 0, 1) == '@') { $msg = ' ' . $msg; } // ERROR] couldn't open file fix //## Own App Post if (!empty($options['fbAppPageAuthToken'])) { if (empty($options['appsecret_proof'])) { $options['appsecret_proof'] = hash_hmac('sha256', $options['fbAppPageAuthToken'], $options['fbAppSec']); } $mssg = array('access_token' => $options['fbAppPageAuthToken'], 'appsecret_proof' => $options['appsecret_proof'], 'method' => 'post', 'message' => $msg); if ($fbPostType == 'I' && trim($imgURL) == '') { $fbPostType = 'T'; } if ($fbPostType == 'A' && !preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $message['url'])) { $badOut['Warning'] = 'Unvalid URL: ' . $message['url'] . '| Will be posting as text message'; $fbPostType = 'T'; } if ($fbPostType == 'A' || $fbPostType == '') { if ($attachType == 'A' || $attachType == 'S') { $attArr = array('name' => $message['urlTitle'], 'caption' => $message['siteName'], 'link' => $message['url'], 'description' => $message['urlDescr']); $mssg = array_merge($mssg, $attArr); } if ($attachType == 'A') { $mssg['actions'] = json_encode(array('name' => $message['siteName'], 'link' => $message['url'])); } if (trim($imgURL) != '') { $mssg['picture'] = $imgURL; } //if (trim($message['videoURL'])!='') $mssg['source'] = $message['videoURL']; } elseif ($fbPostType == 'I') { /* $facebook->setFileUploadSupport(true); */ $fbWhere = 'photos'; $mssg['url'] = $imgURL; if ($options['imgUpl'] == 'T') { //## Try to Post to TImeline $aacct = array('access_token' => $options['fbAppPageAuthToken'], 'appsecret_proof' => $options['appsecret_proof'], 'method' => 'get'); $res = wp_remote_get("https://graph.facebook.com/{$page_id}/albums?" . http_build_query($aacct, null, '&'), $wprg); if (is_wp_error($res) || empty($res['body'])) { $badOut['Error'] = ' [ERROR] ' . print_r($res, true); } else { $albums = json_decode($res['body'], true); if (empty($albums)) { $badOut['Error'] .= "JSON ERROR: " . print_r($res, true); } else { if (is_array($albums) && is_array($albums["data"])) { foreach ($albums["data"] as $album) { if ($album["type"] == "wall") { $chosen_album = $album; break; } } } if (isset($chosen_album) && isset($chosen_album["id"])) { $page_id = $chosen_album["id"]; } } } } } //## Actual Post $destURL = "https://graph.facebook.com/{$page_id}/" . $fbWhere; // prr($destURL); //prr($args); prr($mssg); //die(); $response = wp_remote_post($destURL, array('method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'sslverify' => false, 'redirection' => 0, 'body' => $mssg)); } if (is_wp_error($response) || empty($response['body'])) { return "ERROR: " . print_r($response, true); } $res = json_decode($response['body'], true); if (empty($res)) { return "JSON ERROR: " . print_r($response, true); } if (!empty($res['error'])) { if (!empty($res['error']['message'])) { $badOut['Error'] .= $res['error']['message']; //## Some Known Errors if (stripos($res['error']['message'], 'This API call requires a valid app_id') !== false) { if (!is_numeric($page_id) && stripos($options['fbURL'], '/groups/') != false) { $badOut['Error'] .= ' [ERROR] Unrecognized Facebook Group ID. Please use numeric ID. Please see <a href="http://gd.is/f412">FAQ 4.12</a>'; } else { $badOut['Error'] .= " [ERROR] (invalid app_id) Authorization Error. <br/>\r\n<br/>\r\n Possible Reasons: <br/>\r\n 1. Your app is not authorized. Please go to the Plugin Settings - Facebook and authorize it.<br/>\r\n 2. The current authorized user have no rights to post to the specified page. Please login to Facebook as the correct user and Re-Authorize the Plugin.<br/>\r\n 3. You clicked 'Skip' or unchecked the 'Manage Pages' or 'Post on your behalf' permissions when Authorization wizard asked you. Please Re-Authorize the Plugin<br/>\r\n"; } } if (stripos($res['error']['message'], 'Some of the aliases you requested do not exist') !== false) { $badOut['Error'] .= '| Please check what do you have in the "Facebook URL" field.'; } if (stripos($res['error']['message'], 'The target user has not authorized this action') !== false) { $badOut['Error'] .= '| Please Authorize the plugin from the plugin settings Page - Facebook.'; } return $badOut; } else { return print_r($res['error'], true); } } if (empty($res['id'])) { return print_r($res, true); } //## All Good! $pgID = isset($res['post_id']) && strpos($res['post_id'], '_') !== false ? $res['post_id'] : $res['id']; $pgg = explode('_', $pgID); $postID = $pgg[1]; $pgURL = 'http://www.facebook.com/' . $options['pgID'] . '/posts/' . $postID; return array('isPosted' => '1', 'postID' => $pgID, 'postURL' => $pgURL, 'pDate' => date('Y-m-d H:i:s'), 'log' => $badOut); }
function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['accessToken']) || trim($options['accessToken']) == '') { $badOut['Error'] = 'Not Authorized'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format Post if (!empty($message['pText'])) { $text = $message['pText']; } else { $text = nxs_doFormatMsg($options['msgFrmt'], $message); } if (!empty($message['pTitle'])) { $msgT = $message['pTitle']; } else { $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message); } //## Make Post if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } $postType = $options['postType']; if (empty($imgURL)) { $badOut['Error'] = 'No Image. Flickr is an image-sharing network. You can\'t post to Flickr without image.'; return $badOut; } require_once 'apis/scOAuth.php'; $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']); $tum_oauth->baseURL = 'https://www.flickr.com/services'; $tum_oauth->request_token_path = '/oauth/request_token'; $tum_oauth->access_token_path = '/oauth/access_token'; $tags = $message['tags']; $postArr = array('title' => $msgT, 'description' => $text, 'tags' => $tags, 'is_public' => 1, 'safety_level' => 1, 'content_type' => 1, 'hidden' => 1); $imgFile = $this->createFile($imgURL); if (empty($imgFile) || is_array($imgFile)) { $badOut['Error'] = 'Image Error - ' . print_r($imgFile, true); return $badOut; } $phiID = $tum_oauth->flUploadPhoto($imgFile, $postArr); // prr($phiID); if (!empty($phiID) && strpos($phiID, 'Problem: ') === false) { $params = array('format' => 'php_serial', 'method' => 'flickr.photosets.addPhoto', 'photo_id' => $phiID, 'photoset_id' => $options['setID']); $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/', $params); if (!empty($message['latitude']) && !empty($message['longitude'])) { $params = array('format' => 'php_serial', 'method' => 'flickr.photos.geo.setLocation', 'photo_id' => $phiID, 'lat' => $message['latitude'], 'lon' => $message['longitude']); $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/', $params); } } if (!empty($phiID) && strpos($phiID, 'Problem: ') === false) { return array('postID' => $phiID, 'isPosted' => 1, 'postURL' => str_ireplace('people', 'photos', $options['userURL']) . $phiID, 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= print_r($phiID, true) . " Code:" . $tum_oauth->http_code; return $badOut; } return $badOut; }
function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['trConsKey']) || trim($options['trConsSec']) == '' || empty($options['trAccessTocken'])) { $badOut['Error'] = 'Not Configured'; return $badOut; } if (!isset($options['postType']) && isset($options['trPostType'])) { $options['postType'] = $options['trPostType']; } //## Compatibility with v <3.2 if (empty($options['imgSize'])) { $options['imgSize'] = ''; } if (empty($message['postDate'])) { $message['postDate'] = ''; } if (empty($options['trMsgTFormat'])) { $options['trMsgTFormat'] = '%TITLE%'; } //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['trMsgFormat'], $message); } if (!empty($message['pTitle'])) { $msgT = $message['pTitle']; } else { $msgT = nxs_doFormatMsg($options['trMsgTFormat'], $message); } //## Post $options['trURL'] = trim(str_ireplace('http://', '', $options['trURL'])); if (substr($options['trURL'], -1) == '/') { $options['trURL'] = substr($options['trURL'], 0, -1); } require_once 'apis/trOAuth.php'; $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec']; $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options); $postArr = array('tags' => $message['tags'], 'date' => $message['postDate']); if ($options['fillSrcURL'] == '1') { $postArr['source_url'] = $message['url']; } if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } // postType if ($options['postType'] == 'I') { $postArr['type'] = 'photo'; $postArr['caption'] = $msg; $postArr['source'] = $imgURL; if (!isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') { $postArr['link'] = $message['url']; } elseif ($options['cImgURL'] == 'S') { $postArr['link'] = $message['url']; $postArr['link'] = nxs_mkShortURL($postArr['link']); } } elseif ($options['postType'] == 'U') { $postArr['type'] = 'audio'; $postArr['caption'] = $msg; $postArr['external_url'] = $aUrl; } elseif ($options['postType'] == 'V') { $postArr['type'] = 'video'; $postArr['caption'] = $msg; $embedTxt = '<iframe width="560" height="315" src="http://www.youtube.com/embed/' . $message['videoURL'] . '" frameborder="0" allowfullscreen></iframe>'; $postArr['embed'] = $embedTxt; } else { $postArr['title'] = $msgT; $postArr['type'] = 'text'; $postArr['source'] = $message['url']; $postArr['body'] = $msg; } $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/" . $options['trURL'] . "/post", $postArr); // prr("http://api.tumblr.com/v2/blog/".$options['trURL']."/post"); prr($postinfo); prr($postArr); $code = $postinfo->meta->status; // echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|===="); if ($code == 201) { return array('postID' => $postinfo->response->id, 'isPosted' => 1, 'postURL' => 'http://' . $options['trURL'] . "/post/" . $postinfo->response->id, 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= $code . " - " . $postinfo->meta->msg . (isset($postinfo->errmsg) ? $postinfo->errmsg : '') . " | " . print_r($postinfo, true); } return $badOut; }
function doPostToNT($options, $message) { global $nxs_gCookiesArr; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['pnUName']) || trim($options['pnPass']) == '') { $badOut['Error'] = 'Not Configured'; return $badOut; } $pass = substr($options['pnPass'], 0, 5) == 'g9c1a' ? nsx_doDecode(substr($options['pnPass'], 5)) : $options['pnPass']; if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['pnMsgFormat'], $message); } $boardID = $options['pnBoard']; // prr($boardID); prr($_POST); die(); if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } if ($imgURL == '') { $badOut['Error'] .= 'NO Image.'; } $urlToGo = !empty($message['url']) ? $message['url'] : ''; //## Check for existing session if (isset($options['ck'])) { $nxs_gCookiesArr = maybe_unserialize($options['ck']); } $loginError = true; if (is_array($nxs_gCookiesArr)) { $loginError = doCheckPinterest(); } if ($loginError !== false) { $loginError = doConnectToPinterest($options['pnUName'], $pass); } if ($loginError !== false) { $badOut['Error'] = print_r($loginError, true) . " - BAD USER/PASS"; return $badOut; } if (preg_match('/\\$(\\d+\\.\\d+)/', $msg, $matches)) { $price = $matches[0]; } else { $price = ''; } if (isset($options['cImgURL']) && $options['cImgURL'] == 'S') { $urlToGo = nxs_mkShortURL($urlToGo); } elseif (isset($options['cImgURL']) && $options['cImgURL'] == 'N') { $urlToGo = ''; } $ret = doPostToPinterest($msg, $imgURL, $urlToGo, $boardID, 'TITLE WHERE IS IT?', $price, $urlToGo . "/GTH/"); if ($ret == 'OK') { $ret = array("code" => "OK", "post_id" => ''); } //prr($ret); if (is_array($ret) && !empty($ret['post_id'])) { return array('postID' => str_ireplace('/pin/', '', $ret['post_id']), 'isPosted' => 1, 'postURL' => $ret['post_url'], 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= 'Something went wrong - ' . print_r($ret, true); } return $badOut; }
function doPostToNT($options, $message) { $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); global $nxs_vkCkArray; //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } if ((!isset($options['uName']) || trim($options['uPass']) == '') && (!isset($options['vkAppAuthToken']) || trim($options['vkAppAuthToken']) == '')) { $badOut['Error'] = 'Not Configured'; return $badOut; } $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass']; //## Format if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['msgFrmt'], $message); } $urlToGo = !empty($message['url']) ? $message['url'] : ''; $postType = $options['postType']; //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500)); if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } $msgOpts = array(); $msgOpts['uid'] = $options['vkPgID']; // if ($link!='') $msgOpts['link'] = $link; if (!empty($message['videoURL']) && $postType == "I") { $postType = 'A'; $urlToGo = $message['videoURL']; $msgOpts['vID'] = $vids[0]; } if ($postType == 'I' && trim($imgURL) == '') { $postType = 'T'; } $msgOpts['type'] = $postType; if (function_exists('nxs_doPostToVK') && $postType == 'A' && $urlToGo != '') { //## Login if (isset($options['vkSvC'])) { $nxs_vkCkArray = maybe_unserialize($options['vkSvC']); } $loginError = true; if (is_array($nxs_vkCkArray)) { $loginError = nxs_doCheckVK(); } if ($loginError != false) { if (!empty($options['vkPh'])) { $replArr = explode(' ... ', $options['vkPhReq']); $ph = $options['vkPh']; $ln = strlen($replArr[0]); if (substr($ph, 0, $ln) == $replArr[0]) { $ph = substr($ph, $ln); } $ln = strlen($replArr[1]); $mln = -$ln; if (substr($ph, $mln) == $replArr[1]) { $ph = substr($ph, $ln, $mln); } } else { $ph = ''; } $loginError = nxs_doConnectToVK($options['uName'], $pass, $ph); } // prr($loginError); if ($loginError !== false) { if (stripos($loginError, 'Phone verification required:') !== false) { return $loginError; } else { return "ERROR - BAD USER/PASS - " . print_r($loginError, true); } } //## Post $msgOpts['url'] = $urlToGo; $msgOpts['urlTitle'] = $message['urlTitle']; $msgOpts['urlDesc'] = $message['urlDescr']; $msgOpts['imgURL'] = $imgURL; $ret = nxs_doPostToVK($msg, $options['url'], $msgOpts); if (is_array($ret) && !empty($ret['code']) && $ret['code'] == 'OK') { return array('postID' => $ret['post_id'], 'isPosted' => 1, 'postURL' => 'http://vk.com/wall' . $ret['post_id'], 'pDate' => date('Y-m-d H:i:s')); } else { $badOut .= 'ERROR: ' . print_r($ret, true); } } //prr($postType); if ($postType == 'I') { $imgUpld = $this->nxs_uplImgtoVK($imgURL, $options); if (is_object($imgUpld)) { $imgID = $imgUpld->id; $atts[] = $imgID; } else { $badOut['Error'] .= '-=ERROR=- ' . print_r($imgUpld, true); } } if ($postType != 'A') { if ($options['addBackLink'] == '1') { $atts[] = $urlToGo; } if (is_array($atts)) { $atts = implode(',', $atts); } $postUrl = 'https://api.vkontakte.ru/method/wall.post'; $postArr = array('owner_id' => $options['pgIntID'], 'access_token' => $options['vkAppAuthToken'], 'from_group' => '1', 'message' => $msg, 'attachment' => $atts); $response = wp_remote_post($postUrl, array('body' => $postArr)); if (is_wp_error($response) || is_object($response) && isset($response->errors) || is_array($response) && stripos($response['body'], '"error":') !== false) { $badOut['Error'] .= 'Error: ' . print_r($response['body'], true); } else { $respJ = json_decode($response['body'], true); $ret = $options['pgIntID'] . '_' . $respJ['response']['post_id']; } } if (isset($ret) && $ret != '') { return array('postID' => $ret, 'isPosted' => 1, 'postURL' => 'http://vk.com/wall' . $ret, 'pDate' => date('Y-m-d H:i:s')); } return $badOut; }
function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['uPass']) || trim($options['uPass']) == '') { $badOut['Error'] = 'Not Authorized'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format Post if (!empty($message['pText'])) { $text = $message['pText']; } else { $text = nxs_doFormatMsg($options['msgFrmt'], $message); } //## Make Post if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } //## Make Post if (!empty($options['ck'])) { $ck = maybe_unserialize($options['ck']); $loginError = doCheckFlipboard($ck); } if (empty($ck) || $loginError !== false) { $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass']; $loginInfo = doConnectToFlipboard($options['uName'], $pass); if (!is_array($loginInfo)) { $badOut['Error'] = print_r($loginInfo, true) . " - ERROR"; return $badOut; } $ck = $loginInfo['ck']; } $post = array('url' => $message['url'], 'mgzURL' => $options['mgzURL'], 'imgURL' => $imgURL, 'text' => $text); return doPostToFlipboard($ck, $post); }
function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['apAppAuthToken']) || trim($options['apAppAuthToken']) == '') { $badOut['Error'] = 'Not Authorized'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format Post if (!empty($message['pText'])) { $text = $message['pText']; } else { $text = nxs_doFormatMsg($options['apTextFormat'], $message); } $text = nsTrnc($text, 256); //## Make Post if (isset($message['imageURL'])) { $img = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $img = ''; } if ($options['attchImg'] != false && $img != '') { $remoteImg = $this->createFile($img, $options['apAppAuthToken']); } $ann = array(); if (is_array($remoteImg)) { $ann[] = array("type" => "net.app.core.oembed", "value" => array("+net.app.core.file" => array("file_id" => $remoteImg['id'], "file_token" => $remoteImg['file_token'], "format" => "oembed"))); } $url = "https://alpha-api.app.net/stream/0/posts?include_post_annotations=1&access_token=" . $options['apAppAuthToken']; $flds = array('text' => $text, 'annotations' => $ann); $flds = json_encode($flds); $hdrsArr = array('Content-Type' => 'application/json'); $response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds)); if (is_wp_error($response)) { $badOut['Error'] = print_r($response, true) . " - ERROR"; return $badOut; } $response = json_decode($response['body'], true); //prr($response); die(); //## Check Result if (!is_array($response) || !isset($response['meta']) || $response['meta']['code'] != '200' || $response['data']['canonical_url'] == '') { $badOut['Error'] = print_r($response, true) . " - ERROR"; return $badOut; } $apNewPostURL = $response['data']['canonical_url']; $apNewPostID = $response['data']['id']; if ($apNewPostID != '') { return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= print_r($tmhOAuth->response['response'], true) . " MSG:" . print_r($msg, true); return $badOut; } return $badOut; }
function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); if (!function_exists('nxs_remote_get') && function_exists('wp_remote_get')) { function nxs_remote_get($url) { return wp_remote_get($url); } } if (!function_exists('is_nxs_error') && function_exists('is_wp_error')) { function is_nxs_error($a) { return is_wp_error($a); } } //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['twAccToken']) || trim($options['twAccToken']) == '') { $badOut['Error'] = 'No Auth Token Found'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Old Settings Fix if ($options['attchImg'] == '1') { $options['attchImg'] = 'large'; } if ($options['attchImg'] == '0') { $options['attchImg'] = false; } if (isset($message['img']) && is_string($message['img'])) { $img = trim($message['img']); } else { $img = ''; } //## Format Post if (!empty($message['pText'])) { $msg = $message['pText']; } else { $msg = nxs_doFormatMsg($options['twMsgFormat'], $message); } if ($options['attchImg'] != false) { if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } } if (empty($imgURL) && $img == '') { $options['attchImg'] = false; } //## Make Post //$options['attchImg']='1'; $imgURL = 'http://ecx.images-amazon.com/images/I/41caE5Uc5ML._AA160_.jpg'; $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); //$msg = $message['message']; $imgURL = trim($message['imageURL']); $img = trim($message['img']); $nxs_urlLen = $message['urlLength']; if ($options['attchImg'] != false && $img == '' && $imgURL != '') { $imgURL = str_replace(' ', '%20', $imgURL); if (ini_get('allow_url_fopen')) { if (getimagesize($imgURL) !== false) { $img = nxs_remote_get($imgURL, $advSet); if (is_nxs_error($img)) { $options['attchImg'] = false; } else { $img = $img['body']; } } else { $options['attchImg'] = false; } } else { $img = nxs_remote_get($imgURL, $advSet); if (is_nxs_error($img)) { $options['attchImg'] = false; } elseif (isset($img['body']) && trim($img['body']) != '') { $img = $img['body']; } else { $options['attchImg'] = false; } } } if ($options['attchImg'] != false && $img != '') { $twLim = 118; } else { $twLim = 140; } require_once 'apis/tmhOAuth.php'; if ($nxs_urlLen > 0) { $msg = nsTrnc($msg, $twLim - 22 + $nxs_urlLen); } else { $msg = nsTrnc($msg, $twLim); } //prr($msg); die('TTWWW'); if (substr($msg, 0, 1) == '@') { $msg = ' ' . $msg; } //prr(urlencode($msg)); $msg = html_entity_decode($msg); prr(urlencode($msg)); die(); $tmhOAuth = new NXS_tmhOAuth(array('consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec'])); if ($options['attchImg'] != false && $img != '') { $params_array = array('media[]' => $img, 'status' => $msg); } else { $params_array = array('status' => $msg); } if (!empty($options['in_reply_to_id'])) { $params_array['in_reply_to_status_id'] = $options['in_reply_to_id']; } if ($options['attchImg'] != false && $img != '') { $code = $tmhOAuth->request('POST', 'https://api.twitter.com/1.1/statuses/update_with_media.json', $params_array, true, true); } else { $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), $params_array); } //prr($msg); if ($code == '403' && stripos($tmhOAuth->response['response'], 'User is over daily photo limit') !== false && $options['attchImg'] != false && $img != '') { $badOut['Error'] .= "User is over daily photo limit. Will post without image\r\n"; $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' => $msg)); } if ($code == 200) { $twResp = json_decode($tmhOAuth->response['response'], true); if (is_array($twResp) && isset($twResp['id_str'])) { $twNewPostID = $twResp['id_str']; } if (is_array($twResp) && isset($twResp['user'])) { $twPageID = $twResp['user']['screen_name']; } return array('postID' => $twNewPostID, 'isPosted' => 1, 'postURL' => 'https://twitter.com/' . $twPageID . '/status/' . $twNewPostID, 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= "Resp: " . print_r($tmhOAuth->response['response'], true) . "| Error: " . print_r($tmhOAuth->response['error'], true) . "| MSG: " . print_r($msg, true); return $badOut; } return $badOut; }
function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => ''); //## Check settings if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; } if (!isset($options['accessToken']) || trim($options['accessToken']) == '') { $badOut['Error'] = 'Not Authorized'; return $badOut; } if (empty($options['imgSize'])) { $options['imgSize'] = ''; } //## Format Post if (!empty($message['pText'])) { $text = $message['pText']; } else { $text = nxs_doFormatMsg($options['msgFrmt'], $message); } if (!empty($message['pTitle'])) { $msgT = $message['pTitle']; } else { $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message); } //## Make Post if (isset($message['imageURL'])) { $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); } else { $imgURL = ''; } $postType = $options['postType']; require_once 'apis/scOAuth.php'; $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']); $tiID = $tum_oauth->makeReq('http://www.scoop.it/api/1/topic', array('urlName' => $options['topicURL'])); if (!empty($tiID) && is_array($tiID) && !empty($tiID['topic']) && !empty($tiID['topic']['id'])) { $tiID = $tiID['topic']['id']; } else { $badOut['Error'] .= print_r($tiID, true); return $badOut; } $postArr = array('action' => 'create', 'title' => $msgT, 'content' => $text, 'url' => $postType == 'A' ? $message['url'] : '', 'imageUrl' => ($postType == 'I' || $postType == 'A') && !empty($imgURL) ? $imgURL : '', 'topicId' => $tiID); $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST'); // prr($postinfo); if (is_array($postinfo) && isset($postinfo['post'])) { $apNewPostID = $postinfo['post']['id']; $apNewPostURL = $postinfo['post']['scoopUrl']; if ($options['inclTags'] == '1') { $postArr = array('action' => 'edit', 'tag' => $message['tags'], 'id' => $apNewPostID); $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST'); } } $code = $tum_oauth->http_code; if (!empty($apNewPostID)) { return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s')); } else { $badOut['Error'] .= print_r($postinfo, true) . " Code:" . $tum_oauth->http_code; return $badOut; } return $badOut; }