function nxs_getURL($options, $postID, $addURLParams = '') { global $plgn_NS_SNAutoPoster; $gOptions = $plgn_NS_SNAutoPoster->nxs_options; if (!isset($options['urlToUse']) || trim($options['urlToUse']) == '') { $myurl = trim(get_post_meta($postID, 'snap_MYURL', true)); } $ssl = !empty($gOptions['ht']) && $gOptions['ht'] == ord('h'); if (!empty($myurl)) { $options['urlToUse'] = $myurl; } if (isset($options['urlToUse']) && trim($options['urlToUse']) != '' || $ssl) { $options['atchUse'] = 'F'; } else { $options['urlToUse'] = get_permalink($postID); } $options['urlToUse'] = $ssl ? $gOptions['useSSLCert'] : $options['urlToUse']; // $addURLParams = trim($gOptions['addURLParams']); if ($addURLParams != '') { $options['urlToUse'] .= (strpos($options['urlToUse'], '?') !== false ? '&' : '?') . $addURLParams; } $forceSURL = trim(get_post_meta($postID, '_snap_forceSURL', true)); if (empty($forceSURL)) { $forceSURL = !empty($options['forceSURL']); } else { $forceSURL = $forceSURL == '1'; } if (!empty($options['suUName'])) { $forceSURL = false; } //## SU does not allow Shorteners if ($forceSURL) { $options['urlToUse'] = nxs_mkShortURL($options['urlToUse'], $postID); } return $options; }
function nxs_doPublishToTR($postID, $options) { $ntCd = 'TR'; $ntCdL = 'tr'; $ntNm = 'Tumblr'; //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToTR', array($postID, $options)); $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle == '') { $blogTitle = home_url(); } $ii = $options['ii']; if (!isset($options['pType'])) { $options['pType'] = 'im'; } if ($options['pType'] == 'sh') { sleep(rand(1, 10)); } $logNT = '<span style="color:#014A76">Tumblr</span> - ' . $options['nName']; $snap_ap = get_post_meta($postID, 'snap' . $ntCd, true); $snap_ap = maybe_unserialize($snap_ap); if ($options['pType'] != 'aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) { $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted != '2') { nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:' . $postID, 'Already posted. No reason for posting duplicate' . ' |' . $options['pType']); return; } } //## Format if ($postID == '0') { echo "Testing ... <br/><br/>"; $msg = 'Test Post from ' . $blogTitle; $msgT = 'Test Post from ' . $blogTitle; $options['trPostType'] == 'T'; } else { $post = get_post($postID); if (!$post) { return; } $trMsgFormat = $options['trMsgFormat']; $msg = nsFormatMessage($trMsgFormat, $postID); $trMsgTFormat = $options['trMsgTFormat']; $msgT = nsFormatMessage($trMsgTFormat, $postID); nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted' => '1')); } //prr($options); die(); //## Post require_once 'apis/trOAuth.php'; $consumer_key = $options['trConsKey']; $consumer_secret = $options['trConsSec']; $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']); //prr($options); $trURL = trim(str_ireplace('http://', '', $options['trURL'])); if (substr($trURL, -1) == '/') { $trURL = substr($trURL, 0, -1); } $tggs = array(); if ($options['trInclTags'] == '1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) { $tggs[] = $tagA->name; } $tags = implode(',', $tggs); } if ($options['trInclCats'] == '1') { $t = wp_get_post_categories($postID); foreach ($t as $c) { $cat = get_category($c); $tggs[] = $cat->name; } $tags = implode(',', $tggs); } $postDate = ($post->post_date_gmt != '0000-00-00 00:00:00' ? $post->post_date_gmt : gmdate("Y-m-d H:i:s", strtotime($post->post_date))) . " GMT"; //## Adds date to Tumblr post. Thanks to Kenneth Lecky $extInfo = ' | PostID: ' . $postID . " - " . $post->post_title . ' |' . $options['pType']; $postArr = array('tags' => $tags, 'date' => $postDate); if ($options['trPostType'] == 'V') { $vids = nsFindVidsInPost($post); if (count($vids) > 0) { $ytUrl = $vids[0]; } if (trim($ytUrl) == '') { $options['trPostType'] = 'T'; } } if ($options['trPostType'] == 'U') { $aud = nsFindAudioInPost($post); if (count($aud) > 0) { $aUrl = $aud[0]; } if (trim($aUrl) == '') { $options['trPostType'] = 'T'; } } if ($options['trPostType'] == 'I') { $imgURL = nxs_getPostImage($postID, 'large', $options['trDefImg']); if (trim($imgURL) == '') { $options['trPostType'] = 'T'; } } if ($options['trPostType'] == 'I') { $postArr['type'] = 'photo'; $postArr['caption'] = $msg; $postArr['source'] = $imgURL; if (!isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') { $postArr['link'] = get_permalink($postID); } elseif ($options['cImgURL'] == 'S') { $postArr['link'] = get_permalink($postID); $postArr['link'] = nxs_mkShortURL($postArr['link']); } } elseif ($options['trPostType'] == 'U') { $postArr['type'] = 'audio'; $postArr['caption'] = $msg; $postArr['external_url'] = $aUrl; } elseif ($options['trPostType'] == 'V') { $postArr['type'] = 'video'; $postArr['caption'] = $msg; $embedTxt = '<iframe width="560" height="315" src="http://www.youtube.com/embed/' . $ytUrl . '" frameborder="0" allowfullscreen></iframe>'; $postArr['embed'] = $embedTxt; } else { $postArr['title'] = $msgT; $postArr['type'] = 'text'; $postArr['source'] = get_permalink($postID); $postArr['body'] = $msg; } $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/" . $trURL . "/post", $postArr); // prr($postinfo); prr($postArr); $code = $postinfo->meta->status; // echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|===="); if ($code == 201) { if ($postID == '0') { nxs_addToLogN('S', 'Test', $logNT, 'OK - TEST Message Posted '); echo 'OK - Message Posted, please see your Tumblr Page. <br/> Result:'; prr($postinfo->meta); } else { nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); nxs_metaMarkAsPosted($postID, 'TR', $options['ii'], array('isPosted' => '1', 'pgID' => $postinfo->response->id, 'pDate' => date('Y-m-d H:i:s'))); } } else { nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . print_r($postinfo, true), $extInfo); if ($postID == '0') { prr($postinfo); } $code .= " - " . $postinfo->meta->msg . $postinfo->errmsg; } return $code; }
function nxs_doFormatMsg($format, $message, $addURLParams = '') { global $nxs_urlLen; $msg = nxs_doSpin($format); // prr($msg); prr($message);// Make "message default" $msgDef = array('title' => '', 'announce' => '', 'text' => '', 'url' => '', 'surl' => '', 'urlDescr' => '', 'urlTitle' => '', 'imageURL' => array(), 'videoCode' => '', 'videoURL' => '', 'siteName' => '', 'tags' => '', 'cats' => '', 'authorName' => '', 'orID' => ''); $message = array_merge($msgDef, $message); if (preg_match('/%URL%/', $msg)) { $url = $message['url']; if ($addURLParams != '') { $url .= (strpos($url, '?') !== false ? '&' : '?') . $addURLParams; } $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%URL%", $url, $msg); } if (preg_match('/%SURL%/', $msg)) { if (isset($message['surl']) && $message['surl'] != '') { $url = $message['surl']; } else { $url = $message['url']; if ($addURLParams != '') { $url .= (strpos($url, '?') !== false ? '&' : '?') . $addURLParams; } $url = nxs_mkShortURL($url); } $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%SURL%", $url, $msg); } if (preg_match('/%IMG%/', $msg)) { if (isset($message['imgURL']) && is_array($message['imgURL'])) { $imgURL = trim($message['imgURL']['large']); if ($imgURL == '') { $imgURL = trim($message['imgURL']['medium']); } if ($imgURL == '') { $imgURL = trim($message['imgURL']['original']); } if ($imgURL == '') { $imgURL = trim($message['imgURL']['thumb']); } } elseif (!empty($message['imgURL'])) { $imgURL = $message['imgURL']; } else { $imgURL = ''; } $msg = str_ireplace("%IMG%", $imgURL, $msg); } if (preg_match('/%IMGLARGE%/', $msg)) { $msg = str_ireplace("%IMG%", trim($message['imgURL']['large'], $msg)); } if (preg_match('/%IMGMEDIUM%/', $msg)) { $msg = str_ireplace("%IMGMEDIUM%", trim($message['imgURL']['medium'], $msg)); } if (preg_match('/%IMGTHUMB%/', $msg)) { $msg = str_ireplace("%IMGTHUMB%", trim($message['imgURL']['thumb'], $msg)); } if (preg_match('/%IMGORIGINAL%/', $msg)) { $msg = str_ireplace("%IMGORIGINAL%", trim($message['imgURL']['original'], $msg)); } if (preg_match('/%ORID%/', $msg)) { $msg = str_ireplace("%ORID%", $message['orID'], $msg); } if (preg_match('/%TITLE%/', $msg)) { $msg = str_ireplace("%TITLE%", $message['title'], $msg); } if (preg_match('/%STITLE%/', $msg)) { $title = substr($message['title'], 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); } if (preg_match('/%AUTHORNAME%/', $msg)) { $msg = str_ireplace("%AUTHORNAME%", $message['authorName'], $msg); } if (preg_match('/%SITENAME%/', $msg)) { $msg = str_ireplace("%SITENAME%", $message['siteName'], $msg); } if (preg_match('/%ANNOUNCE%/', $msg)) { $sText = trim($message['announce']) != '' ? $message['announce'] : nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%ANNOUNCE%", $sText, $msg); } if (preg_match('/%EXCERPT%/', $msg)) { $sText = trim($message['announce']) != '' ? $message['announce'] : nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%EXCERPT%", $sText, $msg); } if (preg_match('/%RAWEXCERPT%/', $msg)) { $sText = trim($message['announce']) != '' ? $message['announce'] : nsTrnc($message['description'], 300, " ", "..."); $msg = str_ireplace("%RAWEXCERPT%", $sText, $msg); } if (preg_match('/%TEXT%/', $msg)) { $msg = str_ireplace("%TEXT%", $message['description'], $msg); } if (preg_match('/%FULLTEXT%/', $msg)) { $msg = str_ireplace("%FULLTEXT%", $message['description'], $msg); } if (preg_match('/%RAWTEXT%/', $msg)) { $msg = str_ireplace("%RAWTEXT%", $message['description'], $msg); } if (preg_match('/%TAGS%/', $msg)) { $tags = nxs_doProcessTags($message['tags']); $msg = str_ireplace("%TAGS%", $tags['tags'], $msg); } if (preg_match('/%HTAGS%/', $msg)) { $tags = nxs_doProcessTags($message['tags']); $msg = str_ireplace("%HTAGS%", $tags['htags'], $msg); } if (preg_match('/%CATS%/', $msg)) { $tags = nxs_doProcessTags($message['cats']); $msg = str_ireplace("%CATS%", $tags['cats'], $msg); } if (preg_match('/%HCATS%/', $msg)) { $tags = nxs_doProcessTags($message['hcats']); $msg = str_ireplace("%HCATS%", $tags['hcats'], $msg); } if (preg_match('/%+CF-[a-zA-Z0-9-_]+%/', $msg)) { $msgA = explode('%CF', $msg); $mout = ''; foreach ($msgA as $mms) { if (substr($mms, 0, 1) == '-' && stripos($mms, '%') !== false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = $message[$mGr]; $mms = str_ireplace("-" . $mGr . "%", $cfItem, $mms); } $mout .= $mms; } $msg = $mout; } return trim($msg); }
function nsFormatMessage($msg, $postID, $addURLParams = '') { global $ShownAds, $plgn_NS_SNAutoPoster, $nxs_urlLen; $post = get_post($postID); $options = $plgn_NS_SNAutoPoster->nxs_options; // if ($addURLParams=='' && $options['addURLParams']!='') $addURLParams = $options['addURLParams']; $msg = stripcslashes($msg); if (isset($ShownAds)) { $ShownAdsL = $ShownAds; } // $msg = htmlspecialchars(stripcslashes($msg)); $msg = nxs_doSpin($msg); if (preg_match('%URL%', $msg)) { $url = get_permalink($postID); if ($addURLParams != '') { $url .= (strpos($url, '?') !== false ? '&' : '?') . $addURLParams; } $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%URL%", $url, $msg); } if (preg_match('%SURL%', $msg)) { $url = get_permalink($postID); if ($addURLParams != '') { $url .= (strpos($url, '?') !== false ? '&' : '?') . $addURLParams; } $url = nxs_mkShortURL($url, $postID); $nxs_urlLen = nxs_strLen($url); $msg = str_ireplace("%SURL%", $url, $msg); } if (preg_match('%IMG%', $msg)) { $imgURL = nxs_getPostImage($postID); $msg = str_ireplace("%IMG%", $imgURL, $msg); } if (preg_match('%TITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $msg = str_ireplace("%TITLE%", $title, $msg); } if (preg_match('%STITLE%', $msg)) { $title = nxs_doQTrans($post->post_title, $lng); $title = substr($title, 0, 115); $msg = str_ireplace("%STITLE%", $title, $msg); } if (preg_match('%AUTHORNAME%', $msg)) { $aun = $post->post_author; $aun = get_the_author_meta('display_name', $aun); $msg = str_ireplace("%AUTHORNAME%", $aun, $msg); } if (preg_match('%ANNOUNCE%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); if (stripos($postContent, '<!--more-->') !== false) { $postContentEx = explode('<!--more-->', $postContent); $postContent = $postContentEx[0]; } elseif (stripos($postContent, '<!--more-->') !== false) { $postContentEx = explode('<!--more-->', $postContent); $postContent = $postContentEx[0]; } else { $postContent = nsTrnc($postContent, $options['anounTagLimit']); } $msg = str_ireplace("%ANNOUNCE%", $postContent, $msg); } if (preg_match('%TEXT%', $msg)) { if ($post->post_excerpt != "") { $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); } else { $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); } $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%TEXT%", $excerpt, $msg); } if (preg_match('%EXCERPT%', $msg)) { if ($post->post_excerpt != "") { $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_excerpt, $lng)); } else { $excerpt = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); } $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%EXCERPT%", $excerpt, $msg); } if (preg_match('%RAWEXTEXT%', $msg)) { if ($post->post_excerpt != "") { $excerpt = nxs_doQTrans($post->post_excerpt, $lng); } else { $excerpt = nxs_doQTrans($post->post_content, $lng); } $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXTEXT%", $excerpt, $msg); } if (preg_match('%RAWEXCERPT%', $msg)) { if ($post->post_excerpt != "") { $excerpt = nxs_doQTrans($post->post_excerpt, $lng); } else { $excerpt = nxs_doQTrans($post->post_content, $lng); } $excerpt = nsTrnc(strip_tags(strip_shortcodes($excerpt)), 300, " ", "..."); $msg = str_ireplace("%RAWEXCERPT%", $excerpt, $msg); } if (preg_match('%TAGS%', $msg)) { $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) { $tggs[] = $tagA->name; } $tags = implode(', ', $tggs); $msg = str_ireplace("%TAGS%", $tags, $msg); } if (preg_match('%CATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach ($t as $c) { $cat = get_category($c); $cats[] = str_ireplace('&', '&', $cat->name); } $ctts = implode(', ', $cats); $msg = str_ireplace("%CATS%", $ctts, $msg); } if (preg_match('%HCATS%', $msg)) { $t = wp_get_post_categories($postID); $cats = array(); foreach ($t as $c) { $cat = get_category($c); $cats[] = "#" . trim(str_replace(' ', '', str_replace(' ', '', trim(str_ireplace('&', '', str_ireplace('&', '', $cat->name)))))); } $ctts = implode(', ', $cats); $msg = str_ireplace("%HCATS%", $ctts, $msg); } if (preg_match('%HTAGS%', $msg)) { $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) { $tggs[] = "#" . trim(str_replace(' ', '', preg_replace('/[^a-zA-Z0-9\\p{L}\\p{N}\\s]/u', '', trim(ucwords(str_ireplace('&', '', str_ireplace('&', '', $tagA->name))))))); } $tags = implode(', ', $tggs); $msg = str_ireplace("%HTAGS%", $tags, $msg); } if (preg_match('%CF-[a-zA-Z0-9]%', $msg)) { $msgA = explode('%CF', $msg); $mout = ''; foreach ($msgA as $mms) { if (substr($mms, 0, 1) == '-' && stripos($mms, '%') !== false) { $mGr = CutFromTo($mms, '-', '%'); $cfItem = get_post_meta($postID, $mGr, true); $mms = str_ireplace("-" . $mGr . "%", $cfItem, $mms); } $mout .= $mms; } $msg = $mout; } if (preg_match('%FULLTEXT%', $msg)) { $postContent = apply_filters('the_content', nxs_doQTrans($post->post_content, $lng)); $msg = str_ireplace("%FULLTEXT%", $postContent, $msg); } if (preg_match('%RAWTEXT%', $msg)) { $postContent = nxs_doQTrans($post->post_content, $lng); $msg = str_ireplace("%RAWTEXT%", $postContent, $msg); } if (preg_match('%SITENAME%', $msg)) { $siteTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); $msg = str_ireplace("%SITENAME%", $siteTitle, $msg); } if (isset($ShownAds)) { $ShownAds = $ShownAdsL; } // FIX for the quick-adsense plugin return trim($msg); }
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; }