nxs_class_SNAP_YT

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

Defined (1)

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

/inc-cl/yt.api.php  
  1. if (!class_exists("nxs_class_SNAP_YT")) { class nxs_class_SNAP_YT { 
  2.  
  3. var $ntCode = 'YT'; 
  4. var $ntLCode = 'yt';  
  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. }  
  10. function doPostToNT($options, $message) { $badOut = array('pgID'=>'', 'isPosted'=>0, 'pDate'=>date('Y-m-d H:i:s'), 'Error'=>''); 
  11. //## Check settings 
  12. if (!is_array($options)) { $badOut['Error'] = 'No Options'; return $badOut; }  
  13. if (!isset($options['ytUName']) || trim($options['ytPass'])=='') { $badOut['Error'] = 'Not Configured'; return $badOut; } $email = $options['ytUName'];  
  14. $pass = substr($options['ytPass'], 0, 5)=='n5g9a'?nsx_doDecode(substr($options['ytPass'], 5)):$options['ytPass'];  
  15. //## Format 
  16. if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['ytMsgFormat'], $message);  
  17.  
  18. $nt = new nxsAPI_GP(); if(!empty($options['ck'])) $nt->ck = $options['ck']; $nt->debug = false; $loginError = $nt->connect($email, $pass, 'YT');  
  19. if (!$loginError) {  
  20. $result = $nt -> postYT($msg, $options['ytPageID'], $message['videoURL'], $options['ytGPPageID']);  
  21. } else { $badOut['Error'] = "Login/Connection Error: ". print_r($loginError, true); return $badOut; }  
  22. if (is_array($result) && $result['isPosted']=='1') nxs_save_glbNtwrks('yt', $options['ii'], $nt->ck, 'ck'); 
  23. return $result;  
  24. }  
  25. }}