nxs_doPublishToLJ

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

Description

nxs_doPublishToLJ( $postID, $options ); 

Parameters (2)

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

Usage

  1. if ( !function_exists( 'nxs_doPublishToLJ' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/inc-cl/lj.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_doPublishToLJ($postid, $options); 
  12.  

Defined (1)

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

/inc-cl/lj.php  
  1. function nxs_doPublishToLJ($postID, $options) { $ntCd = 'LJ'; $ntCdL = 'lj'; $ntNm = 'LJ Based Blog'; if (!is_array($options)) $options = maybe_unserialize(get_post_meta($postID, $options, true)); 
  2. //if (isset($options['timeToRun'])) wp_unschedule_event( $options['timeToRun'], 'nxs_doPublishToLJ', array($postID, $options));  
  3. $blogTitle = htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES); if ($blogTitle=='') $blogTitle = home_url();  
  4. $addParams = nxs_makeURLParams(array('NTNAME'=>$ntNm, 'NTCODE'=>$ntCd, 'ACCNAME'=>$options['nName'], 'POSTID'=>$postID)); 
  5. $ii = $options['ii']; if (!isset($options['pType'])) $options['pType'] = 'im'; if ($options['pType']=='sh') sleep(rand(1, 10));  
  6. $logNT = '<span style="color:#2097EE">LJ</span> - '.$options['nName']; 
  7. $snap_ap = get_post_meta($postID, 'snap'.$ntCd, true); $snap_ap = maybe_unserialize($snap_ap);  
  8. if ($options['pType']!='aj' && is_array($snap_ap) && (nxs_chArrVar($snap_ap[$ii], 'isPosted', '1') || nxs_chArrVar($snap_ap[$ii], 'isPrePosted', '1'))) { 
  9. $snap_isAutoPosted = get_post_meta($postID, 'snap_isAutoPosted', true); if ($snap_isAutoPosted!='2') {  
  10. nxs_addToLogN('W', 'Notice', $logNT, '-=Duplicate=- Post ID:'.$postID, 'Already posted. No reason for posting duplicate'.' |'.$uqID); return; 
  11. }  
  12. //$imgURL = nxs_getPostImage($postID); 
  13. $email = $options['ljUName']; $pass = substr($options['ljPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ljPass'], 5)):$options['ljPass'];  
  14. if ($postID=='0') { echo "Testing ... <br/><br/>"; $options['ljMsgTFormat'] = 'Test Link from '. home_url(); $options['ljMsgFormat'] = 'Test post please ignore'; } else { $post = get_post($postID); if(!$post) return;  
  15. $options['ljMsgFormat'] = nsFormatMessage($options['ljMsgFormat'], $postID, $addParams); $options['ljMsgTFormat'] = nsFormatMessage($options['ljMsgTFormat'], $postID, $addParams);  
  16. nxs_metaMarkAsPosted($postID, $ntCd, $options['ii'], array('isPrePosted'=>'1'));  
  17. } //prr($msg); prr($msgFormat); 
  18. $extInfo = ' | PostID: '.$postID." - ".(isset($post) && is_object($post)?$post->post_title:''); 
  19. //## Post  
  20. $t = wp_get_post_tags($postID); $tggs = array(); foreach ($t as $tagA) {$tggs[] = $tagA->name;} $tags = implode(', ', $tggs); 
  21. $message = array('siteName'=>$blogTitle, 'tags'=>$tags);// prr($message); 
  22. //## Actual Post 
  23. $ntToPost = new nxs_class_SNAP_LJ(); $ret = $ntToPost->doPostToNT($options, $message); 
  24. //## Process Results 
  25. if (!is_array($ret) || $ret['isPosted']!='1') { //## Error  
  26. if ($postID=='0') prr($ret); nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- '.print_r($ret, true), $extInfo);  
  27. } else { // ## All Good - log it. 
  28. 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'); }  
  29. 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); } 
  30. //## Return Result 
  31. if ($ret['isPosted']=='1') return 200; else return print_r($ret, true);