nxs_class_SNAP_FP

The NextScripts: Social Networks Auto-Poster nxs class SNAP FP class.

Defined (1)

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

/inc-cl/fp.api.php  
  1. if (!class_exists("nxs_class_SNAP_FP")) { class nxs_class_SNAP_FP { 
  2.  
  3. var $ntCode = 'FP'; 
  4. var $ntLCode = 'fp'; 
  5.  
  6. function createFile($imgURL) { 
  7. $remImgURL = urldecode($imgURL); $urlParced = pathinfo($remImgURL); $remImgURLFilename = $urlParced['basename'];  
  8. $imgData = wp_remote_get($remImgURL); if (is_wp_error($imgData)) { $badOut['Error'] = print_r($imgData, true)." - ERROR"; return $badOut; }  
  9. $imgData = $imgData['body']; 
  10. $tmp=array_search('uri', @array_flip(stream_get_meta_data($GLOBALS[mt_rand()]=tmpfile())));  
  11. if (!is_writable($tmp)) return "Your temporary folder or file (file - ".$tmp.") is not witable. Can't upload images to Flickr"; 
  12. rename($tmp, $tmp.='.png'); register_shutdown_function(create_function('', "unlink('{$tmp}');"));  
  13. file_put_contents($tmp, $imgData); if (!$tmp) return 'You must specify a path to a file'; if (!file_exists($tmp)) return 'File path specified does not exist'; 
  14. if (!is_readable($tmp)) return 'File path specified is not readable';  
  15. // $data['name'] = basename($tmp); 
  16. return "@$tmp"; 
  17.  
  18.  
  19. function doPost($options, $message) { if (!is_array($options)) return false; $out = array(); // return false; 
  20. foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message); 
  21. return $out; 
  22.  
  23. function doPostToNT($options, $message) { global $nxs_urlLen; $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); 
  24. //## Check settings 
  25. if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }  
  26. if (!isset($options['uPass']) || trim($options['uPass'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }  
  27. if (empty($options['imgSize'])) $options['imgSize'] = ''; 
  28. //## Format Post 
  29. if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFrmt'], $message);  
  30. //## Make Post  
  31. if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = '';  
  32. //## Make Post  
  33. if (!empty($options['ck'])) {$ck = maybe_unserialize($options['ck']); $loginError = doCheckFlipboard($ck);} 
  34. if (empty($ck) || $loginError!==false) { $pass = substr($options['uPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['uPass'], 5)):$options['uPass'];  
  35. $loginInfo = doConnectToFlipboard($options['uName'], $pass); if (!is_array($loginInfo)) { $badOut['Error'] = print_r($loginInfo, true)." - ERROR"; return $badOut; } $ck = $loginInfo['ck'];  
  36. } $post = array('url'=>$message['url'], 'mgzURL'=>$options['mgzURL'], 'imgURL'=>$imgURL, 'text'=>$text ); 
  37. return doPostToFlipboard($ck, $post);  
  38. }  
  39. }}