nxs_class_SNAP_SC

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

Defined (1)

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

/inc-cl/sc.api.php  
  1. if (!class_exists("nxs_class_SNAP_SC")) { class nxs_class_SNAP_SC { 
  2.  
  3. var $ntCode = 'SC'; 
  4. var $ntLCode = 'sc'; 
  5.  
  6. function doPost($options, $message) { if (!is_array($options)) return false; $out = array(); // return false; 
  7. foreach ($options as $ii=>$ntOpts) $out[$ii] = $this->doPostToNT($ntOpts, $message); 
  8. return $out; 
  9.  
  10. function doPostToNT($options, $message) { global $nxs_urlLen; $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['accessToken']) || trim($options['accessToken'])=='') { $badOut['Error'] = 'Not Authorized'; return $badOut; }  
  14. if (empty($options['imgSize'])) $options['imgSize'] = ''; 
  15. //## Format Post 
  16. if (!empty($message['pText'])) $text = $message['pText']; else $text = nxs_doFormatMsg($options['msgFrmt'], $message); 
  17. if (!empty($message['pTitle'])) $msgT = $message['pTitle']; else $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);  
  18. //## Make Post  
  19. if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; $postType = $options['postType'];  
  20.  
  21. require_once('apis/scOAuth.php'); $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']); 
  22. $tiID = $tum_oauth->makeReq('http://www.scoop.it/api/1/topic', array('urlName'=>$options['topicURL']));  
  23. if (!empty($tiID) && is_array($tiID) && !empty($tiID['topic']) && !empty($tiID['topic']['id'])) $tiID = $tiID['topic']['id']; else { $badOut['Error'] .= print_r($tiID, true); return $badOut; } 
  24. $postArr = array('action'=>'create', 'title'=>$msgT, 'content'=>$text, 'url'=>$postType=='A'?$message['url']:'', 'imageUrl'=>(($postType=='I' || $postType=='A') && !empty($imgURL))?$imgURL:'', 'topicId'=>$tiID);  
  25. $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST'); // prr($postinfo); 
  26.  
  27. if (is_array($postinfo) && isset($postinfo['post'])) { $apNewPostID = $postinfo['post']['id']; $apNewPostURL = $postinfo['post']['scoopUrl'];  
  28. if ($options['inclTags']=='1') { $postArr = array('action'=>'edit', 'tag'=>$message['tags'], 'id'=>$apNewPostID);  
  29. $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST');  
  30.  
  31. } $code = $tum_oauth->http_code; 
  32. if (!empty($apNewPostID)) {  
  33. return array('postID'=>$apNewPostID, 'isPosted'=>1, 'postURL'=>$apNewPostURL, 'pDate'=>date('Y-m-d H:i:s'));  
  34. } else { $badOut['Error'] .= print_r($postinfo, true)." Code:".$tum_oauth->http_code;  
  35. return $badOut; 
  36. return $badOut; 
  37. }  
  38.  
  39. }}