nxs_class_SNAP_PK

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

Defined (1)

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

/inc-cl/pk.api.php  
  1. if (!class_exists("nxs_class_SNAP_PK")) { class nxs_class_SNAP_PK { 
  2.  
  3. var $ntCode = 'PK'; 
  4. var $ntLCode = 'pk';  
  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['pkConsKey']) || trim($options['pkConsSec'])=='' || empty($options['pkAccessTocken'])) { $badOut['Error'] = 'Not Configured'; return $badOut; }  
  14. if (empty($options['imgSize'])) $options['imgSize'] = '';  
  15. //## Format 
  16. if (!empty($message['pText'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['pkMsgFormat'], $message);  
  17. //## Post  
  18. require_once('apis/plurkOAuth.php'); $consumer_key = $options['pkConsKey']; $consumer_secret = $options['pkConsSec']; 
  19. $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkAccessTocken'], $options['pkAccessTockenSec']);  
  20. $pkURL = trim(str_ireplace('http://', '', $options['pkURL'])); if (substr($pkURL, -1)=='/') $pkURL = substr($pkURL, 0, -1);  
  21. if ($options['pkCat']=='') $options['pkCat'] = ':';  
  22. if ($options['attchImg']=='1') { if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; if ($imgURL!='') $msg .= " ".$imgURL; }  
  23.  
  24. $postArr = array('content'=>$msg, 'qualifier'=>$options['pkCat']); $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr); // prr($postinfo); 
  25. if (is_array($postinfo) && isset($postinfo['plurk_id'])) $pkID = $postinfo['plurk_id']; $code = $tum_oauth->http_code; // echo "XX".print_r($code); prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|===="); 
  26.  
  27. if ($code == 200 && $pkID!='') { $alphabet = str_split("0123456789abcdefghijklmnopqrstuvwxyz"); $shorten = ''; $plurk_id = $pkID; 
  28. while ($plurk_id != 0) { $i = $plurk_id % 36; $plurk_id = intval($plurk_id / 36); $shorten = $alphabet[$i].$shorten;} $link = 'http://www.plurk.com/p/'.$shorten; 
  29. return array('postID'=>$pkID, 'isPosted'=>1, 'postURL'=>$link, 'pDate'=>date('Y-m-d H:i:s'));  
  30. } else { $badOut['Error'] .= " ERROR: - ".$postinfo['error_text']; }  
  31. return $badOut; 
  32. }  
  33. }}