nxs_class_SNAP_GP

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

Defined (1)

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

/inc-cl/gp.api.php  
  1. if (!class_exists("nxs_class_SNAP_GP")) { class nxs_class_SNAP_GP { 
  2.  
  3. var $ntCode = 'GP'; 
  4. var $ntLCode = 'gp';  
  5.  
  6. function doPost($options, $message) { if (!is_array($options)) return false; $out = array(); 
  7. foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message); 
  8. return $out; 
  9. function doPostToNT($options, $message) { $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); $lnk = ''; 
  10. //## Check API Lib 
  11. // 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');  
  12. if (!function_exists('doPostToGooglePlus')) { $badOut['Error'] = 'Google+ API Library not found'; return $badOut; } 
  13. //## Check settings 
  14. if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }  
  15. if (!isset($options['gpUName']) || trim($options['gpPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; } 
  16. if (empty($options['imgSize'])) $options['imgSize'] = ''; 
  17. //## Make Post  
  18. $gpPostType = $options['postType'];  
  19. if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message); // Make "message default" 
  20. if ($gpPostType=='I' || $gpPostType=='A') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; }  
  21.  
  22. $email = $options['gpUName']; $pass = substr($options['gpPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['gpPass'], 5)):$options['gpPass'];  
  23.  
  24. $nt = new nxsAPI_GP(); if(!empty($options['ck'])) $nt->ck = $options['ck']; $nt->debug = false; $loginError = $nt->connect($email, $pass);  
  25. if (!$loginError) {  
  26. if ($gpPostType=='A') $lnk = $message['url']; elseif ($gpPostType=='I') { $lnk = array(); if ($imgURL!='') $lnk['img'] = $imgURL; if ($imgURL=='' && $message['noImg']===true) $lnk['img'] = ''; 
  27. if (!empty($message['videoURL'])) $lnk['video'] = $message['videoURL'];  
  28. } $pageID = ''; $comPgID = ''; $comPGCatID = ''; 
  29. //if (!empty($options['gpPageID']) && empty($options['gpCommID'])) $pageID = $options['gpPageID'];  
  30. if (!empty($options['gpPageID'])) $pageID = $options['gpPageID'];  
  31. if (!empty($options['gpCommID'])) {$comPgID = $options['gpCommID']; $comPGCatID = $options['gpCCat'];} 
  32. $result = $nt -> postGP($msg, $lnk, $pageID, $comPgID, $comPGCatID); 
  33. } else { $badOut['Error'] = "Login/Connection Error: ". print_r($loginError, true); return $badOut; }  
  34. if (is_array($result) && $result['isPosted']=='1') nxs_save_glbNtwrks('gp', $options['ii'], $nt->ck, 'ck'); 
  35. return $result; 
  36.  
  37. }}