nxs_doPublishToFL

The NextScripts: Social Networks Auto-Poster nxs doPublishToFL function.

Description

nxs_doPublishToFL( $postID, $options ); 

Parameters (2)

0. $postid
The postid.
1. $options
The options.

Usage

  1. if ( !function_exists( 'nxs_doPublishToFL' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/inc-cl/fl.php'; 
  3.  
  4. // The postid. 
  5. $postid = null; 
  6.  
  7. // The options. 
  8. $options = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = nxs_doPublishToFL($postid, $options); 
  12.  

Defined (1)

The function is defined in the following location(s).

/inc-cl/fl.php  
  1. function nxs_doPublishToFL($postID, $options) { $ntCd = 'FL'; $ntCdL = 'fl'; $ntNm = 'Flickr'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); 
  2. $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'POSTID'=>$postID, 'ACCNAME'=>$options['nName'])); 
  3. if (empty($options['imgToUse'])) $options['imgToUse'] = ''; if (empty($options['imgSize'])) $options['imgSize'] = ''; 
  4. $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10)); 
  5. $logNT = '<span style="color:#800000">Flickr</span> - '.$options['nName']; 
  6. $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap); 
  7. if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) { 
  8. $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') { 
  9. nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'); return; 
  10. $message = array('message'=>'', 'link'=>'', 'imageURL'=>'', 'videoURL'=>'', 'announce'=>''); 
  11.  
  12. if ($postID=='0') { echo "Testing ... <br/><br/>"; $message['description'] = 'Test Post, Description'; $message['title'] = 'Test Post - Title'; $message['url'] = home_url(); $message['tags']=''; 
  13. if ($options['defImg']!='') $imgURL = $options['defImg']; else $imgURL ="http://direct.gtln.us/img/nxs/NXS-Lama.jpg"; $message['imageURL'] = $imgURL; 
  14. } else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1')); $post = get_post($postID); if(!$post) return; 
  15. $isNoImg = false; $tags = ''; 
  16.  
  17. $options['msgFrmt'] = nsFormatMessage($options['msgFrmt'], $postID, $addParams); $options['msgTFrmt'] = nsFormatMessage($options['msgTFrmt'], $postID, $addParams); 
  18.  
  19. $tggs = array(); if ($options['inclTags']=='1') { $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = '"'.implode('" "', $tggs).'"'; } 
  20.  
  21. $imgURL = nxs_getPostImage($postID, 'full'); if (preg_match("/noImg.\.png/i", $imgURL)) { $imgURL = ''; $isNoImg = true; } 
  22.  
  23. $options = nxs_getURL($options, $postID); $urlToGo = $options['urlToUse']; 
  24.  
  25. $message = array('url'=>$urlToGo, 'imageURL'=>$imgURL, 'noImg'=>$isNoImg, 'tags'=>$tags); 
  26.  
  27. $lat = get_post_meta($postID, 'geo_latitude', true); 
  28. $long = get_post_meta($postID, 'geo_longitude', true); 
  29. if (!empty($lat) && !empty($long)) { 
  30. $message['latitude'] = $lat; 
  31. $message['longitude'] = $long; 
  32.  
  33. $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:''); 
  34. //## Actual Post 
  35. $ntToPost = new nxs_class_SNAP_FL(); $ret = $ntToPost->doPostToNT($options, $message); //prr($ret); 
  36. //## Process Results 
  37. if (!is_array($ret) || $ret['isPosted']!='1') { //## Error 
  38. if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo); 
  39. } else { // ## All Good - log it. 
  40. 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'); } 
  41. else { nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPosted'=>'1', 'pgID'=>$ret['postID'], 'postURL'=>$ret['postURL'], 'pDate'=>date('Y-m-d H:i:s'))); 
  42. $extInfo .= ' | <a href="'.$ret['postURL'].'" target="_blank">Post Link</a>'; nxs_addToLogN('S', 'Posted', $logNT, 'OK - Message Posted ', $extInfo); 
  43. //## Return Result 
  44. if ($ret['isPosted']=='1') return 200; else return print_r($ret, true); 
  45.