nxs_class_SNAP_XI

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

Defined (1)

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

/inc-cl/xi.api.php  
  1. if (!class_exists("nxs_class_SNAP_XI")) { class nxs_class_SNAP_XI { 
  2.  
  3. var $ntCode = 'XI'; 
  4. var $ntLCode = 'xi'; 
  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'])) $msg = $message['pText']; else $msg = nxs_doFormatMsg($options['msgFrmt'], $message);  
  17. //## Make Post  
  18. if (isset($message['imageURL'])) $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize'])); else $imgURL = ''; $postType = $options['postType'];  
  19.  
  20. require_once('apis/scOAuth.php'); $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']); 
  21. $tum_oauth->baseURL = 'https://api.xing.com';  
  22.  
  23. $msg = str_replace(''', "'", $msg); $msg = str_replace(''', "'", $msg); $msg = str_replace('#039;', "'", $msg); $msg = str_replace('#039', "'", $msg); 
  24. $msg = str_replace('’', "'", $msg); $msg = str_replace('’', "'", $msg); $msg = str_replace('#8217;', "'", $msg); $msg = str_replace('#8217', "'", $msg); 
  25. $msg = str_replace('“', '"', $msg); $msg = str_replace('“', '"', $msg); $msg = str_replace('#8220;', '"', $msg); $msg = str_replace('#8220', "'", $msg); 
  26. $msg = str_replace('”', '"', $msg); $msg = str_replace('”', '"', $msg); $msg = str_replace('#8221;', '"', $msg); $msg = str_replace('#8221', "'", $msg); 
  27. $msg = str_replace('—', '-', $msg); $msg = str_replace('—', '-', $msg); $msg = str_replace('#8212;', '-', $msg); $msg = str_replace('#8212', "-", $msg);  
  28.  
  29. if ($postType=='A') { $postArr = array('uri'=> urlencode($message['url']), 'text'=>nsTrnc($msg, 420));  
  30. $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/me/share/link', $postArr, 'POST');  
  31. } else { $postArr = array('message'=>nsTrnc($msg, 420), 'id'=>$options['appAppUserID']);  
  32. $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/'.$options['appAppUserID'].'/status_message', $postArr, 'POST'); // prr($postinfo); 
  33.  
  34. $code = $tum_oauth->http_code; if ($code=='201') { if (!empty($postinfo) && is_array($postinfo) && !empty($postinfo['ids']) && !empty($postinfo['ids'][0])) $apNewPostID = $postinfo['ids'][0];  
  35. $np = explode('_', $apNewPostID); $apNewPostURL = 'https://www.xing.com/feedy/stories/'.$np[0];  
  36. } else {$apNewPostID = ''; $apNewPostURL = 'https://www.xing.com/profile/'.$options['appPGUserName'].'/activities'; } 
  37. if (!empty($apNewPostID) || $code=='201') {  
  38. return array('postID'=>$apNewPostID, 'isPosted'=>1, 'postURL'=>$apNewPostURL, 'pDate'=>date('Y-m-d H:i:s'));  
  39. } else { $badOut['Error'] .= print_r($postinfo, true)." Code:".$tum_oauth->http_code;  
  40. return $badOut; 
  41. return $badOut; 
  42. }  
  43.  
  44. }}