function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['ytUName']) || trim($options['ytPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $pass = substr($options['ytPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['ytPass'], 5)) : $options['ytPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['ytMsgFormat'], $message);
     }
     $loginError = doConnectToGooglePlus2($options['ytUName'], $pass, 'YT');
     if ($loginError !== false) {
         return "BAD USER/PASS - " . $loginError;
     }
     $ret = doPostToYouTube($msg, $options['ytPageID'], $message['videoURL'], $options['ytGPPageID']);
     //prr($ret);
     if ($ret == 'OK') {
         $ret = array("code" => "OK", "post_id" => '');
     }
     if (!is_array($ret) && $ret != 'OK') {
         $badOut['Error'] .= 'Something went wrong - NO PID ' . print_r($ret, true);
     } else {
         return array('postID' => $ret['post_id'], 'isPosted' => 1, 'postURL' => $ret['post_id'], 'pDate' => date('Y-m-d H:i:s'));
     }
     return $badOut;
 }
コード例 #2
0
ファイル: lj.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['ljUName']) || trim($options['ljPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $pass = substr($options['ljPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['ljPass'], 5)) : $options['ljPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['ljMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['ljMsgTFormat'], $message);
     }
     require_once 'apis/xmlrpc-client.php';
     if (!empty($options['ljSrv']) && $options['ljSrv'] == 'DW') {
         $server = 'dreamwidth.org';
     } else {
         $server = 'livejournal.com';
     }
     $nxsToLJclient = new NXS_XMLRPC_Client('http://www.' . $server . '/interface/xmlrpc');
     $nxsToLJclient->debug = false;
     $date = time();
     $year = date("Y", $date);
     $mon = date("m", $date);
     $day = date("d", $date);
     $hour = date("G", $date);
     $min = date("i", $date);
     $nxsToLJContent = array("username" => $options['ljUName'], "password" => $pass, "event" => $msg, "subject" => $msgT, "lineendings" => "unix", "year" => $year, "mon" => $mon, "day" => $day, "hour" => $hour, "min" => $min, "ver" => 2);
     if (!empty($options['commID']) && $options['commID'] != '') {
         $nxsToLJContent["usejournal"] = $options['commID'];
     }
     if (!empty($options['inclTags']) && $options['inclTags'] == '1' && !empty($message['tags'])) {
         $nxsToLJContent['props'] = array('taglist' => $message['tags']);
     }
     // prr($nxsToLJContent);
     if (!$nxsToLJclient->query('LJ.XMLRPC.postevent', $nxsToLJContent)) {
         prr($nxsToLJclient);
         $ret = 'Something went wrong - ' . $nxsToLJclient->getErrorCode() . ' : ' . $nxsToLJclient->getErrorMessage();
     } else {
         $ret = 'OK';
     }
     $pid = $nxsToLJclient->getResponse();
     if (is_array($pid) && !empty($pid['url'])) {
         return array('postID' => $pid['url'], 'isPosted' => 1, 'postURL' => $pid['url'], 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= 'Something went wrong - NO PID ' . print_r($pid, true);
     }
     return $badOut;
 }
コード例 #3
0
ファイル: ip.api.php プロジェクト: voquanghoa/WebPhim
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['ipUName']) || trim($options['ipPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $dusername = $options['ipUName'];
     $pass = substr($options['ipPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['ipPass'], 5)) : $options['ipPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['ipMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['ipMsgTFormat'], $message);
     }
     $link = urlencode($message['url']);
     $desc = urlencode(substr($msgT, 0, 250));
     $ext = urlencode(substr($msg, 0, 1000));
     $tags = $message['tags'];
     $apicall = "https://www.instapaper.com/api/add?red=api&url={$link}&title={$desc}&selection={$ext}";
     // prr($apicall);
     $hdrsArr = $this->nxs_getIPHeaders($dusername . ':' . $pass);
     $cnt = wp_remote_get($apicall, array('method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr));
     //  prr($cnt);
     if (is_wp_error($cnt)) {
         $error_string = $cnt->get_error_message();
         if (stripos($error_string, ' timed out') !== false) {
             sleep(10);
             $cnt = wp_remote_get($apicall, array('method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr));
         }
     }
     if (is_wp_error($cnt)) {
         $ret = 'Something went wrong - ' . print_r($cnt, true);
     } else {
         if (is_array($cnt) && stripos($cnt['body'], '201') !== false) {
             return array('postID' => 'IP', 'isPosted' => 1, 'postURL' => 'IP', 'pDate' => date('Y-m-d H:i:s'));
         } else {
             $ret = "Error: ";
             if (is_array($cnt) && $cnt['response']['code'] == '401') {
                 $ret .= " Incorrect Username/Password ";
             } else {
                 $ret .= print_r($cnt, true);
             }
             $ret .= $cnt['response']['message'];
         }
     }
     $badOut['Error'] .= $ret;
     return $badOut;
 }
コード例 #4
0
ファイル: ff.api.php プロジェクト: voquanghoa/WebPhim
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['ffUName']) || trim($options['ffPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $dusername = $options['ffUName'];
     $pass = substr($options['ffPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['ffPass'], 5)) : $options['ffPass'];
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['ffMsgFormat'], $message);
     }
     if ($options['attchImg'] == '1') {
         if (isset($message['imageURL'])) {
             $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
         } else {
             $imgURL = '';
         }
     } else {
         $imgURL = '';
     }
     $postArr = array('title' => $msg, 'image0_link' => '', 'room' => $options['grpID'] != '' ? strtolower($options['grpID']) : '', 'image0_url' => $imgURL != '' ? $imgURL : '');
     $apicall = "http://friendfeed.com/api/share";
     $hdrsArr = $this->nxs_getFFHeaders($dusername . ':' . $pass);
     $paramcall = array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body' => $postArr, 'headers' => $hdrsArr);
     $cnt = wp_remote_post($apicall, $paramcall);
     // prr(json_decode($cnt['body'], true));
     if (is_wp_error($cnt)) {
         $ret = 'Something went wrong - ' . print_r($cnt, true);
     } else {
         if (is_array($cnt)) {
             $retInfo = json_decode($cnt['body'], true);
         } else {
             $retInfo = false;
         }
         if (is_array($cnt) && $cnt['response']['code'] == '200' && is_array($retInfo)) {
             return array('postID' => $retInfo['entries'][0]['id'], 'isPosted' => 1, 'postURL' => 'http://friendfeed.com/e/' . $retInfo['entries'][0]['id'], 'pDate' => date('Y-m-d H:i:s'));
         } else {
             $ret = "Error: ";
             if ($cnt['response']['code'] == '401') {
                 $ret .= " Incorrect Username/Password ";
             }
             $ret .= $cnt['response']['message'];
         }
     }
     $badOut['Error'] .= $ret;
     return $badOut;
 }
コード例 #5
0
ファイル: dl.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['dlUName']) || trim($options['dlPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $email = $options['dlUName'];
     $pass = substr($options['dlPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['dlPass'], 5)) : $options['dlPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['dlMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['dlMsgTFormat'], $message);
     }
     $tags = nsTrnc($message['tags'], 195, ',', '');
     $link = $message['url'];
     $desc = substr($msgT, 0, 250);
     $ext = substr($msg, 0, 1000);
     $hdrsArr = $this->getHeaders('https://delicious.com', 'https://delicious.com', true);
     $flds = array('username' => $email, 'password' => base64_encode(strrev($pass)));
     $cnt = wp_remote_post('https://avosapi.delicious.com/api/v1/account/login', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body' => $flds, 'headers' => $hdrsArr));
     if (is_nxs_error($cnt)) {
         $badOut = "ERROR (Login Form): " . print_r($rep, true);
         return $badOut;
     }
     $rep = json_decode($cnt['body'], true);
     if ($rep['status'] != 'success') {
         $badOut = "ERROR (Login): " . print_r($rep, true);
         return $badOut;
     }
     $ck = $cnt['cookies'];
     $flds = array('url' => $link, 'description' => $desc, 'tags' => $tags, 'note' => $ext, 'replace' => 'true', 'private' => 'false', 'share' => '');
     $advSts = array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'body' => $flds, 'cookies' => $ck, 'headers' => $hdrsArr);
     //prr($advSts);
     $cnt = wp_remote_post('https://avosapi.delicious.com/api/v1/posts/addoredit', $advSts);
     if (is_nxs_error($cnt)) {
         $badOut = "ERROR (Login Form): " . print_r($rep, true);
         return $badOut;
     }
     $rep = json_decode($cnt['body'], true);
     if ($rep['status'] != 'success') {
         $badOut = "ERROR (Login): " . print_r($rep, true);
         return $badOut;
     }
     return array('postID' => md5($message['url']), 'isPosted' => 1, 'postURL' => 'https://delicious.com/link/' . md5($message['url']), 'pDate' => date('Y-m-d H:i:s'));
 }
コード例 #6
0
ファイル: di.api.php プロジェクト: voquanghoa/WebPhim
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['diUName']) || trim($options['diPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $email = $options['diUName'];
     $pass = substr($options['diPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['diPass'], 5)) : $options['diPass3'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['diMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['diMsgTFormat'], $message);
     }
     $flds = array();
     $flds['key'] = $options['diAPIKey'];
     $flds['url'] = $message['url'];
     $flds['title'] = nsTrnc($msgT, 250);
     $flds['desc'] = nsTrnc($msg, 250);
     $flds['tags'] = $message['tags'];
     $flds['shared'] = 'yes';
     //   prr($flds); die();
     $hdrsArr = $this->nxs_getDIHeaders('https://secure.diigo.com/api/v2/bookmarks', $email, $pass, true);
     $cnt = wp_remote_post('https://secure.diigo.com/api/v2/bookmarks', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
     //## Return
     if (is_array($cnt) && stripos($cnt['body'], '"code":1') !== false) {
         return array('postID' => 'DI', 'isPosted' => 1, 'postURL' => 'DI', 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($cnt, true);
         return $badOut;
     }
 }
コード例 #7
0
ファイル: yt.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['ytUName']) || trim($options['ytPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $email = $options['ytUName'];
     $pass = substr($options['ytPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['ytPass'], 5)) : $options['ytPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['ytMsgFormat'], $message);
     }
     $nt = new nxsAPI_GP();
     if (!empty($options['ck'])) {
         $nt->ck = $options['ck'];
     }
     $nt->debug = false;
     $loginError = $nt->connect($email, $pass, 'YT');
     if (!$loginError) {
         $result = $nt->postYT($msg, $options['ytPageID'], $message['videoURL'], $options['ytGPPageID']);
     } else {
         $badOut['Error'] = "Login/Connection Error: " . print_r($loginError, true);
         return $badOut;
     }
     if (is_array($result) && $result['isPosted'] == '1') {
         nxs_save_glbNtwrks('yt', $options['ii'], $nt->ck, 'ck');
     }
     return $result;
 }
コード例 #8
0
ファイル: pk.api.php プロジェクト: voquanghoa/WebPhim
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['pkConsKey']) || trim($options['pkConsSec']) == '' || empty($options['pkAccessTocken'])) {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['pkMsgFormat'], $message);
     }
     //## Post
     require_once 'apis/plurkOAuth.php';
     $consumer_key = $options['pkConsKey'];
     $consumer_secret = $options['pkConsSec'];
     $tum_oauth = new wpPlurkOAuth($consumer_key, $consumer_secret, $options['pkAccessTocken'], $options['pkAccessTockenSec']);
     $pkURL = trim(str_ireplace('http://', '', $options['pkURL']));
     if (substr($pkURL, -1) == '/') {
         $pkURL = substr($pkURL, 0, -1);
     }
     if ($options['pkCat'] == '') {
         $options['pkCat'] = ':';
     }
     if ($options['attchImg'] == '1') {
         if (isset($message['imageURL'])) {
             $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
         } else {
             $imgURL = '';
         }
         if ($imgURL != '') {
             $msg .= " " . $imgURL;
         }
     }
     $postArr = array('content' => $msg, 'qualifier' => $options['pkCat']);
     $postinfo = $tum_oauth->makeReq('http://www.plurk.com/APP/Timeline/plurkAdd', $postArr);
     //  prr($postinfo);
     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("|====");
     if ($code == 200 && $pkID != '') {
         $alphabet = str_split("0123456789abcdefghijklmnopqrstuvwxyz");
         $shorten = '';
         $plurk_id = $pkID;
         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;
         return array('postID' => $pkID, 'isPosted' => 1, 'postURL' => $link, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= " ERROR: - " . $postinfo['error_text'];
     }
     return $badOut;
 }
コード例 #9
0
ファイル: da.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut = 'No Options';
         return $badOut;
     }
     if (!isset($options['daUName']) || trim($options['daUName']) == '' || !isset($options['daPass']) || trim($options['daPass']) == '') {
         $badOut = 'No username/password Found';
         return $badOut;
     }
     //## Format Post
     if (!empty($message['pTitle'])) {
         $title = $message['pTitle'];
     } else {
         $title = nxs_doFormatMsg($options['daTitleFormat'], $message);
     }
     $title = nsTrnc($title, 300);
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['daTextFormat'], $message);
     }
     //## Make Post
     if (!empty($options['ck'])) {
         $ck = maybe_unserialize($options['ck']);
     }
     if (!empty($options['mh'])) {
         $mh = maybe_unserialize($options['mh']);
     }
     $pass = substr($options['daPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['daPass'], 5)) : $options['uPass'];
     $nt = new nxsAPI_DA();
     $nt->debug = false;
     if (!empty($ck)) {
         $nt->ck = $ck;
     }
     if (!empty($mh)) {
         $nt->mh = $mh;
     }
     $loginErr = $nt->connect($options['daUName'], $pass);
     if (!$loginErr) {
         $post = array('title' => $title, 'text' => $text);
         $ret = $nt->post($post);
         if (is_array($ret)) {
             $ret['ck'] = $nt->ck;
             $ret['mh'] = $nt->mh;
             return $ret;
         } else {
             return print_r($ret, true);
         }
     } else {
         return print_r($loginErr, true);
     }
 }
コード例 #10
0
ファイル: xi.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['accessToken']) || trim($options['accessToken']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $postType = $options['postType'];
     require_once 'apis/scOAuth.php';
     $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
     $tum_oauth->baseURL = 'https://api.xing.com';
     $msg = str_replace(''', "'", $msg);
     $msg = str_replace(''', "'", $msg);
     $msg = str_replace('#039;', "'", $msg);
     $msg = str_replace('#039', "'", $msg);
     $msg = str_replace('’', "'", $msg);
     $msg = str_replace('’', "'", $msg);
     $msg = str_replace('#8217;', "'", $msg);
     $msg = str_replace('#8217', "'", $msg);
     $msg = str_replace('“', '"', $msg);
     $msg = str_replace('“', '"', $msg);
     $msg = str_replace('#8220;', '"', $msg);
     $msg = str_replace('#8220', "'", $msg);
     $msg = str_replace('”', '"', $msg);
     $msg = str_replace('”', '"', $msg);
     $msg = str_replace('#8221;', '"', $msg);
     $msg = str_replace('#8221', "'", $msg);
     $msg = str_replace('—', '-', $msg);
     $msg = str_replace('—', '-', $msg);
     $msg = str_replace('#8212;', '-', $msg);
     $msg = str_replace('#8212', "-", $msg);
     if ($postType == 'A') {
         $postArr = array('uri' => urlencode($message['url']), 'text' => nsTrnc($msg, 420));
         $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/me/share/link', $postArr, 'POST');
     } else {
         $postArr = array('message' => nsTrnc($msg, 420), 'id' => $options['appAppUserID']);
         $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/' . $options['appAppUserID'] . '/status_message', $postArr, 'POST');
         // prr($postinfo);
     }
     $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];
         }
         $np = explode('_', $apNewPostID);
         $apNewPostURL = 'https://www.xing.com/feedy/stories/' . $np[0];
     } else {
         $apNewPostID = '';
         $apNewPostURL = 'https://www.xing.com/profile/' . $options['appPGUserName'] . '/activities';
     }
     if (!empty($apNewPostID) || $code == '201') {
         return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($postinfo, true) . " Code:" . $tum_oauth->http_code;
         return $badOut;
     }
     return $badOut;
 }
コード例 #11
0
ファイル: st.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['uPass']) || trim($options['uPass']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     //## Make Post
     if (!empty($options['ck'])) {
         $ck = maybe_unserialize($options['ck']);
     }
     $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass'];
     $nt = new nxsAPI_ST();
     $nt->debug = false;
     if (!empty($ck)) {
         $nt->ck = $ck;
     }
     $loginErr = $nt->connect($options['uName'], $pass);
     if (!$loginErr) {
         $post = array('url' => $message['url'], 'toURL' => $options['mgzURL'], 'imgURL' => $imgURL, 'title' => $msgT, 'text' => $text);
         $ret = $nt->post($post);
         if (is_array($ret)) {
             $ret['ck'] = $nt->ck;
             return $ret;
         } else {
             return print_r($ret, true);
         }
     } else {
         return print_r($loginErr, true);
     }
 }
コード例 #12
0
ファイル: wp.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['wpUName']) || trim($options['wpPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $pass = substr($options['wpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['wpPass'], 5)) : $options['wpPass'];
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['wpMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['wpMsgTFormat'], $message);
     }
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $link = urlencode($message['url']);
     $ext = substr($msg, 0, 1000);
     //## Fix missing xmlrpc.php
     if (substr($options['wpURL'], -1) == '/') {
         $options['wpURL'] = substr($options['wpURL'], 0, -1);
     }
     if (substr($options['wpURL'], -10) != 'xmlrpc.php') {
         $options['wpURL'] .= "/xmlrpc.php";
     }
     //## Post
     require_once 'apis/xmlrpc-client.php';
     $nxsToWPclient = new NXS_XMLRPC_Client($options['wpURL']);
     $nxsToWPclient->debug = false;
     if ($imgURL !== '' && stripos($imgURL, 'http') !== false) {
         // $handle = fopen($imgURL, "rb"); $filedata = ''; while (!feof($handle)) {$filedata .= fread($handle, 8192);} fclose($handle);
         $filedata = wp_remote_get($imgURL);
         if (!is_wp_error($filedata)) {
             $filedata = $filedata['body'];
         }
         // echo "AWC?";
         $data = array('name' => 'image-' . $message['orID'] . '.jpg', 'type' => 'image/jpg', 'bits' => new NXS_XMLRPC_Base64($filedata), true);
         $status = $nxsToWPclient->query('metaWeblog.newMediaObject', $message['orID'], $options['wpUName'], $pass, $data);
         $imgResp = $nxsToWPclient->getResponse();
         $gid = $imgResp['id'];
     } else {
         $gid = '';
     }
     $params = array(0, $options['wpUName'], $pass, array('software_version'));
     if (!$nxsToWPclient->query('wp.getOptions', $params)) {
         $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage();
     } else {
         $ret = 'OK';
     }
     $rwpOpt = $nxsToWPclient->getResponse();
     if (!empty($rwpOpt['software_version'])) {
         $rwpOpt = $rwpOpt['software_version']['value'];
         $rwpOpt = floatval($rwpOpt);
     } else {
         $rwpOpt = 0;
     }
     //prr($rwpOpt);prr($nxsToWPclient);
     //## MAIN Post
     if ($rwpOpt == 0) {
         $errMsg = $nxsToWPclient->getErrorMessage();
         if ($errMsg != '') {
             $ret = $errMsg;
         } else {
             $ret = 'XMLRPC is not found or not active. WP admin - Settings - Writing - Enable XML-RPC';
         }
     } else {
         if ($rwpOpt < 3.0) {
             $ret = 'XMLRPC is too OLD - ' . $rwpOpt . ' You need at least 3.0';
         } else {
             if ($rwpOpt > 3.3) {
                 $nxsToWPContent = array('title' => $msgT, 'description' => $msg, 'post_status' => 'draft', 'mt_excerpt' => $ext, 'mt_allow_comments' => 1, 'mt_allow_pings' => 1, 'post_type' => 'post', 'mt_keywords' => $message['tags'], 'categories' => $message['cats'], 'custom_fields' => '');
                 $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
                 if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) {
                     $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage();
                 } else {
                     $ret = 'OK';
                 }
                 $pid = $nxsToWPclient->getResponse();
                 if ($gid != '') {
                     $nxsToWPContent = array('post_thumbnail' => $gid);
                     $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true);
                     if (!$nxsToWPclient->query('wp.editPost', $params)) {
                         $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage();
                     } else {
                         $ret = 'OK';
                     }
                 }
                 $nxsToWPContent = array('post_status' => 'publish');
                 $params = array(0, $options['wpUName'], $pass, $pid, $nxsToWPContent, true);
                 if (!$nxsToWPclient->query('wp.editPost', $params)) {
                     $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage();
                 } else {
                     $ret = 'OK';
                 }
             } else {
                 $nxsToWPContent = array('title' => $msgT, 'description' => $msg, 'post_status' => 'publish', 'mt_allow_comments' => 1, 'mt_allow_pings' => 1, 'post_type' => 'post', 'mt_keywords' => $message['tags'], 'categories' => $message['cats'], 'custom_fields' => '');
                 $params = array(0, $options['wpUName'], $pass, $nxsToWPContent, true);
                 if (!$nxsToWPclient->query('metaWeblog.newPost', $params)) {
                     $ret = 'Something went wrong - ' . $nxsToWPclient->getErrorCode() . ' : ' . $nxsToWPclient->getErrorMessage();
                 } else {
                     $ret = 'OK';
                 }
                 $pid = $nxsToWPclient->getResponse();
             }
         }
     }
     if ($ret != 'OK') {
         $badOut['Error'] .= '-=ERROR=- ' . print_r($ret, true);
     } else {
         $wpURL = str_ireplace('/xmlrpc.php', '', $options['wpURL']);
         if (substr($wpURL, -1) == '/') {
             $wpURL = substr($wpURL, 0, -1);
         }
         $wpURL .= '/?p=' . $pid;
         return array('postID' => $pid, 'isPosted' => 1, 'postURL' => $wpURL, 'pDate' => date('Y-m-d H:i:s'));
     }
     return $badOut;
 }
 function doPostToNT($options, $message)
 {
     $badOut = array('Warning' => '', 'Error' => '');
     $wprg = array('sslverify' => false);
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (empty($options['fbAppAuthToken']) && empty($options['atpKey']) && empty($options['uName'])) {
         $badOut['Error'] = 'No Auth Token Found/Not configured';
         return $badOut;
     }
     //## Make Post
     // $facebook = new NXS_Facebook(array( 'appId' => $options['fbAppID'], 'secret' => $options['fbAppSec'], 'cookie' => true ));
     if (!empty($options['fbAppAuthToken'])) {
         if (!isset($options['fbAppPageAuthToken']) || trim($options['fbAppPageAuthToken']) == '') {
             $options['fbAppPageAuthToken'] = $options['fbAppAuthToken'];
         }
     }
     //## Some OLD Format Conversion
     if (!isset($options['attachType']) && isset($options['fbAttch'])) {
         $options['attachType'] = $options['fbAttch'];
     }
     if (!isset($options['postType']) && isset($options['fbPostType'])) {
         $options['postType'] = $options['fbPostType'];
     }
     $fbPostType = $options['postType'];
     //## Compatibility with v <3.2
     if (!isset($options['pgID']) && isset($options['fbPgID'])) {
         $options['pgID'] = $options['fbPgID'];
     }
     if ($fbPostType != 'I' && $fbPostType != 'T') {
         $url = $message['url'];
         $flds = array('id' => $url, 'scrape' => 'true');
         sleep(2);
     }
     //## Get URL info.
     if ($fbPostType != 'I' && $fbPostType != 'T' && !empty($options['atchUse']) && $options['atchUse'] == 'F') {
         $response = wp_remote_post('http://graph.facebook.com', array('body' => $flds, 'sslverify' => false));
         if (is_wp_error($response)) {
             $badOut['Error'] = print_r($response, true) . " - ERROR";
         } else {
             $response = json_decode($response['body'], true);
             //  prr($response);     die();
             if (!empty($response['description'])) {
                 $message['urlDescr'] = $response['description'];
             }
             if (!empty($response['title'])) {
                 $message['urlTitle'] = $response['title'];
             }
             if (!empty($response['site_name'])) {
                 $message['siteName'] = $response['site_name'];
             } elseif ($message['siteName'] == '') {
                 $message['siteName'] = $message['title'];
             }
             if (!empty($response['image'][0]['url'])) {
                 $message['imageURL'] = $response['image'][0]['url'];
             }
         }
     }
     // prr($message);
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['fbMsgFormat'], $message);
     }
     $imgURL = nxs_getImgfrOpt($message['imageURL']);
     $fbWhere = 'feed';
     $attachType = $options['attachType'];
     if ($attachType == '1') {
         $attachType = 'A';
     } else {
         $attachType = 'S';
     }
     if ($options['imgUpl'] != '2') {
         $options['imgUpl'] = 'T';
     } else {
         $options['imgUpl'] = 'A';
     }
     if (stripos($options['fbURL'], '/groups/') != false) {
         $options['destType'] == 'gr';
     }
     if (!empty($options['destType']) && $options['destType'] == 'pr') {
         $page_id = $options['fbAppAuthUser'];
     } else {
         $page_id = $options['pgID'];
     }
     $msg = strip_tags($msg);
     $msg = str_ireplace('&lt;(")', '<(")', $msg);
     //## FB Smiles FIX 3
     if (substr($msg, 0, 1) == '@') {
         $msg = ' ' . $msg;
     }
     // ERROR] couldn't open file fix
     //## Own App Post
     if (!empty($options['fbAppPageAuthToken'])) {
         if (empty($options['appsecret_proof'])) {
             $options['appsecret_proof'] = hash_hmac('sha256', $options['fbAppPageAuthToken'], $options['fbAppSec']);
         }
         $mssg = array('access_token' => $options['fbAppPageAuthToken'], 'appsecret_proof' => $options['appsecret_proof'], 'method' => 'post', 'message' => $msg);
         if ($fbPostType == 'I' && trim($imgURL) == '') {
             $fbPostType = 'T';
         }
         if ($fbPostType == 'A' && !preg_match("/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i", $message['url'])) {
             $badOut['Warning'] = 'Unvalid URL: ' . $message['url'] . '| Will be posting as text message';
             $fbPostType = 'T';
         }
         if ($fbPostType == 'A' || $fbPostType == '') {
             if ($attachType == 'A' || $attachType == 'S') {
                 $attArr = array('name' => $message['urlTitle'], 'caption' => $message['siteName'], 'link' => $message['url'], 'description' => $message['urlDescr']);
                 $mssg = array_merge($mssg, $attArr);
             }
             if ($attachType == 'A') {
                 $mssg['actions'] = json_encode(array('name' => $message['siteName'], 'link' => $message['url']));
             }
             if (trim($imgURL) != '') {
                 $mssg['picture'] = $imgURL;
             }
             //if (trim($message['videoURL'])!='') $mssg['source'] = $message['videoURL'];
         } elseif ($fbPostType == 'I') {
             /* $facebook->setFileUploadSupport(true); */
             $fbWhere = 'photos';
             $mssg['url'] = $imgURL;
             if ($options['imgUpl'] == 'T') {
                 //## Try to Post to TImeline
                 $aacct = array('access_token' => $options['fbAppPageAuthToken'], 'appsecret_proof' => $options['appsecret_proof'], 'method' => 'get');
                 $res = wp_remote_get("https://graph.facebook.com/{$page_id}/albums?" . http_build_query($aacct, null, '&'), $wprg);
                 if (is_wp_error($res) || empty($res['body'])) {
                     $badOut['Error'] = ' [ERROR] ' . print_r($res, true);
                 } else {
                     $albums = json_decode($res['body'], true);
                     if (empty($albums)) {
                         $badOut['Error'] .= "JSON ERROR: " . print_r($res, true);
                     } else {
                         if (is_array($albums) && is_array($albums["data"])) {
                             foreach ($albums["data"] as $album) {
                                 if ($album["type"] == "wall") {
                                     $chosen_album = $album;
                                     break;
                                 }
                             }
                         }
                         if (isset($chosen_album) && isset($chosen_album["id"])) {
                             $page_id = $chosen_album["id"];
                         }
                     }
                 }
             }
         }
         //## Actual Post
         $destURL = "https://graph.facebook.com/{$page_id}/" . $fbWhere;
         // prr($destURL); //prr($args);   prr($mssg); //die();
         $response = wp_remote_post($destURL, array('method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'sslverify' => false, 'redirection' => 0, 'body' => $mssg));
     }
     if (is_wp_error($response) || empty($response['body'])) {
         return "ERROR: " . print_r($response, true);
     }
     $res = json_decode($response['body'], true);
     if (empty($res)) {
         return "JSON ERROR: " . print_r($response, true);
     }
     if (!empty($res['error'])) {
         if (!empty($res['error']['message'])) {
             $badOut['Error'] .= $res['error']['message'];
             //## Some Known Errors
             if (stripos($res['error']['message'], 'This API call requires a valid app_id') !== false) {
                 if (!is_numeric($page_id) && stripos($options['fbURL'], '/groups/') != false) {
                     $badOut['Error'] .= ' [ERROR] Unrecognized Facebook Group ID. Please use numeric ID. Please see <a href="http://gd.is/f412">FAQ 4.12</a>';
                 } else {
                     $badOut['Error'] .= " [ERROR] (invalid app_id) Authorization Error. <br/>\r\n<br/>\r\n Possible Reasons: <br/>\r\n 1. Your app is not authorized. Please go to the Plugin Settings - Facebook and authorize it.<br/>\r\n 2. The current authorized user have no rights to post to the specified page. Please login to Facebook as the correct user and Re-Authorize the Plugin.<br/>\r\n 3. You clicked 'Skip' or unchecked the 'Manage Pages' or 'Post on your behalf' permissions when Authorization wizard asked you. Please Re-Authorize the Plugin<br/>\r\n";
                 }
             }
             if (stripos($res['error']['message'], 'Some of the aliases you requested do not exist') !== false) {
                 $badOut['Error'] .= '| Please check what do you have in the "Facebook URL" field.';
             }
             if (stripos($res['error']['message'], 'The target user has not authorized this action') !== false) {
                 $badOut['Error'] .= '| Please Authorize the plugin from the plugin settings Page - Facebook.';
             }
             return $badOut;
         } else {
             return print_r($res['error'], true);
         }
     }
     if (empty($res['id'])) {
         return print_r($res, true);
     }
     //## All Good!
     $pgID = isset($res['post_id']) && strpos($res['post_id'], '_') !== false ? $res['post_id'] : $res['id'];
     $pgg = explode('_', $pgID);
     $postID = $pgg[1];
     $pgURL = 'http://www.facebook.com/' . $options['pgID'] . '/posts/' . $postID;
     return array('isPosted' => '1', 'postID' => $pgID, 'postURL' => $pgURL, 'pDate' => date('Y-m-d H:i:s'), 'log' => $badOut);
 }
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['uPass']) || trim($options['uPass']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     //## Make Post
     if (!empty($options['ck'])) {
         $ck = maybe_unserialize($options['ck']);
         $loginError = doCheckFlipboard($ck);
     }
     if (empty($ck) || $loginError !== false) {
         $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass'];
         $loginInfo = doConnectToFlipboard($options['uName'], $pass);
         if (!is_array($loginInfo)) {
             $badOut['Error'] = print_r($loginInfo, true) . " - ERROR";
             return $badOut;
         }
         $ck = $loginInfo['ck'];
     }
     $post = array('url' => $message['url'], 'mgzURL' => $options['mgzURL'], 'imgURL' => $imgURL, 'text' => $text);
     return doPostToFlipboard($ck, $post);
 }
コード例 #15
0
ファイル: bg.api.php プロジェクト: voquanghoa/WebPhim
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //prr($message); prr($options);
     //## Check API Lib
     //if (!function_exists('doConnectToBlogger')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['bgUName']) || trim($options['bgPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['bgMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['bgMsgTFormat'], $message);
     }
     if ($options['bgInclTags'] == '1') {
         $tags = nsTrnc($message['tags'], 195, ',', '');
     } else {
         $tags = '';
     }
     //## Check/Fix HTML
     if (class_exists('DOMDocument')) {
         $doc = new DOMDocument();
         @$doc->loadHTML('<?xml encoding="UTF-8">' . $msg);
         $doc->encoding = 'UTF-8';
         $msg = $doc->saveHTML();
         $msg = CutFromTo($msg, '<body>', '</body>');
         $msg = preg_replace('/<br(.*?)\\/?>/', '<br$1/>', $msg);
         $msg = preg_replace('/<img(.*?)\\/?>/', '<img$1/>', $msg);
         require 'apis/htmlNumTable.php';
         if (is_array($HTML401NamedToNumeric)) {
             $msg = strtr($msg, $HTML401NamedToNumeric);
             $msgT = strtr($msgT, $HTML401NamedToNumeric);
         }
     }
     $msg = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $msg);
     $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg);
     $nxshf = new NXS_HtmlFixer();
     $nxshf->debug = false;
     $msg = $nxshf->getFixedHtml($msg);
     $msg = str_replace("\r\n", "\n", $msg);
     $msg = str_replace("\n\r", "\n", $msg);
     $msg = str_replace("\r", "\n", $msg);
     $msg = str_replace("\n", "<br/>", $msg);
     //## Make Post
     $email = $options['bgUName'];
     $pass = substr($options['bgPass'], 0, 5) == 'b4d7s' ? nsx_doDecode(substr($options['bgPass'], 5)) : $options['bgPass'];
     $blogID = $options['bgBlogID'];
     // prr($msgT); prr($msg); die();
     if (function_exists("doConnectToBlogger")) {
         $auth = doConnectToBlogger($email, $pass);
         if ($auth !== false) {
             $ret = $auth;
         } else {
             $ret = doPostToBlogger($blogID, $msgT, $msg, $tags);
         }
     } else {
         $auth = $this->nsBloggerGetAuth($email, $pass);
         if ($auth === false) {
             $ret = 'Incorrect Username/Password';
         } else {
             if (is_array($auth)) {
                 $ret = $auth['error'];
             } else {
                 $msgT = str_ireplace('&amp;', '&', $msgT);
                 $msgT = utf8_encode(str_ireplace('&', '&amp;', $msgT));
                 $msg = utf8_encode($msg);
                 $ret = $this->nsBloggerNewPost($auth, $blogID, $msgT, $msg);
             }
         }
     }
     //## Return
     if (is_array($ret) && $ret['post_id'] != '') {
         return array('postID' => $ret['post_id'], 'isPosted' => 1, 'postURL' => $ret['post_id'], 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($ret, true);
         return $badOut;
     }
 }
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['apAppAuthToken']) || trim($options['apAppAuthToken']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['apTextFormat'], $message);
     }
     $text = nsTrnc($text, 256);
     //## Make Post
     if (isset($message['imageURL'])) {
         $img = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $img = '';
     }
     if ($options['attchImg'] != false && $img != '') {
         $remoteImg = $this->createFile($img, $options['apAppAuthToken']);
     }
     $ann = array();
     if (is_array($remoteImg)) {
         $ann[] = array("type" => "net.app.core.oembed", "value" => array("+net.app.core.file" => array("file_id" => $remoteImg['id'], "file_token" => $remoteImg['file_token'], "format" => "oembed")));
     }
     $url = "https://alpha-api.app.net/stream/0/posts?include_post_annotations=1&access_token=" . $options['apAppAuthToken'];
     $flds = array('text' => $text, 'annotations' => $ann);
     $flds = json_encode($flds);
     $hdrsArr = array('Content-Type' => 'application/json');
     $response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
     if (is_wp_error($response)) {
         $badOut['Error'] = print_r($response, true) . " - ERROR";
         return $badOut;
     }
     $response = json_decode($response['body'], true);
     //prr($response); die();
     //## Check Result
     if (!is_array($response) || !isset($response['meta']) || $response['meta']['code'] != '200' || $response['data']['canonical_url'] == '') {
         $badOut['Error'] = print_r($response, true) . " - ERROR";
         return $badOut;
     }
     $apNewPostURL = $response['data']['canonical_url'];
     $apNewPostID = $response['data']['id'];
     if ($apNewPostID != '') {
         return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($tmhOAuth->response['response'], true) . " MSG:" . print_r($msg, true);
         return $badOut;
     }
     return $badOut;
 }
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     $lnk = '';
     //## Check API Lib
     // 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');
     if (!function_exists('doPostToGooglePlus')) {
         $badOut['Error'] = 'Google+ API Library not found';
         return $badOut;
     }
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['gpUName']) || trim($options['gpPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Make Post
     $gpPostType = $options['postType'];
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message);
     }
     // Make "message default"
     if ($gpPostType == 'I' || $gpPostType == 'A') {
         if (isset($message['imageURL'])) {
             $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
         } else {
             $imgURL = '';
         }
     }
     $email = $options['gpUName'];
     $pass = substr($options['gpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['gpPass'], 5)) : $options['gpPass'];
     $loginError = doConnectToGooglePlus2($email, $pass);
     if ($loginError !== false) {
         $badOut['Error'] = print_r($loginError, true) . " - BAD USER/PASS";
         return $badOut;
     }
     if ($gpPostType == 'I') {
         $lnk = array();
     }
     if ($gpPostType == 'A') {
         $lnk = doGetGoogleUrlInfo2($message['url']);
     }
     if (is_array($lnk) && $imgURL != '') {
         $lnk['img'] = $imgURL;
     }
     if (is_array($lnk) && $imgURL == '' && $message['noImg'] === true) {
         $lnk['img'] = '';
     }
     // prr($lnk); prr($message); die();
     if ($gpPostType == 'I' && !empty($message['videoURL'])) {
         $lnk['video'] = $message['videoURL'];
     }
     if (!empty($options['gpPageID']) && empty($options['gpCommID'])) {
         $to = $options['gpPageID'];
         $ret = doPostToGooglePlus2($msg, $lnk, $to);
     } elseif (!empty($options['gpCommID'])) {
         $ret = doPostToGooglePlus2($msg, $lnk, $options['gpPageID'], $options['gpCommID'], $options['gpCCat']);
     } else {
         $ret = doPostToGooglePlus2($msg, $lnk);
     }
     if (!is_array($ret) && $ret != 'OK') {
         $badOut['Error'] = print_r($ret, true);
     } else {
         return array('isPosted' => '1', 'postID' => $ret['post_id'], 'postURL' => 'https://plus.google.com/' . $ret['post_id'], 'pDate' => date('Y-m-d H:i:s'));
     }
     return $badOut;
 }
コード例 #18
0
ファイル: gp.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     $lnk = '';
     //## Check API Lib
     // 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');
     if (!function_exists('doPostToGooglePlus')) {
         $badOut['Error'] = 'Google+ API Library not found';
         return $badOut;
     }
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['gpUName']) || trim($options['gpPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Make Post
     $gpPostType = $options['postType'];
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['gpMsgFormat'], $message);
     }
     // Make "message default"
     if ($gpPostType == 'I' || $gpPostType == 'A') {
         if (isset($message['imageURL'])) {
             $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
         } else {
             $imgURL = '';
         }
     }
     $email = $options['gpUName'];
     $pass = substr($options['gpPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['gpPass'], 5)) : $options['gpPass'];
     $nt = new nxsAPI_GP();
     if (!empty($options['ck'])) {
         $nt->ck = $options['ck'];
     }
     $nt->debug = false;
     $loginError = $nt->connect($email, $pass);
     if (!$loginError) {
         if ($gpPostType == 'A') {
             $lnk = $message['url'];
         } elseif ($gpPostType == 'I') {
             $lnk = array();
             if ($imgURL != '') {
                 $lnk['img'] = $imgURL;
             }
             if ($imgURL == '' && $message['noImg'] === true) {
                 $lnk['img'] = '';
             }
             if (!empty($message['videoURL'])) {
                 $lnk['video'] = $message['videoURL'];
             }
         }
         $pageID = '';
         $comPgID = '';
         $comPGCatID = '';
         //if (!empty($options['gpPageID']) && empty($options['gpCommID']))  $pageID = $options['gpPageID'];
         if (!empty($options['gpPageID'])) {
             $pageID = $options['gpPageID'];
         }
         if (!empty($options['gpCommID'])) {
             $comPgID = $options['gpCommID'];
             $comPGCatID = $options['gpCCat'];
         }
         $result = $nt->postGP($msg, $lnk, $pageID, $comPgID, $comPGCatID);
     } else {
         $badOut['Error'] = "Login/Connection Error: " . print_r($loginError, true);
         return $badOut;
     }
     if (is_array($result) && $result['isPosted'] == '1') {
         nxs_save_glbNtwrks('gp', $options['ii'], $nt->ck, 'ck');
     }
     return $result;
 }
コード例 #19
0
ファイル: fl.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['accessToken']) || trim($options['accessToken']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $postType = $options['postType'];
     if (empty($imgURL)) {
         $badOut['Error'] = 'No Image. Flickr is an image-sharing network. You can\'t post to Flickr without image.';
         return $badOut;
     }
     require_once 'apis/scOAuth.php';
     $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
     $tum_oauth->baseURL = 'https://www.flickr.com/services';
     $tum_oauth->request_token_path = '/oauth/request_token';
     $tum_oauth->access_token_path = '/oauth/access_token';
     $tags = $message['tags'];
     $postArr = array('title' => $msgT, 'description' => $text, 'tags' => $tags, 'is_public' => 1, 'safety_level' => 1, 'content_type' => 1, 'hidden' => 1);
     $imgFile = $this->createFile($imgURL);
     if (empty($imgFile) || is_array($imgFile)) {
         $badOut['Error'] = 'Image Error - ' . print_r($imgFile, true);
         return $badOut;
     }
     $phiID = $tum_oauth->flUploadPhoto($imgFile, $postArr);
     // prr($phiID);
     if (!empty($phiID) && strpos($phiID, 'Problem: ') === false) {
         $params = array('format' => 'php_serial', 'method' => 'flickr.photosets.addPhoto', 'photo_id' => $phiID, 'photoset_id' => $options['setID']);
         $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/', $params);
         if (!empty($message['latitude']) && !empty($message['longitude'])) {
             $params = array('format' => 'php_serial', 'method' => 'flickr.photos.geo.setLocation', 'photo_id' => $phiID, 'lat' => $message['latitude'], 'lon' => $message['longitude']);
             $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/', $params);
         }
     }
     if (!empty($phiID) && strpos($phiID, 'Problem: ') === false) {
         return array('postID' => $phiID, 'isPosted' => 1, 'postURL' => str_ireplace('people', 'photos', $options['userURL']) . $phiID, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($phiID, true) . " Code:" . $tum_oauth->http_code;
         return $badOut;
     }
     return $badOut;
 }
コード例 #20
0
ファイル: kt.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['uName']) || trim($options['uPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $email = $options['uName'];
     $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['msgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
     }
     //######  ===============
     $hdrsArr = $this->nxs_getKTHeaders('https://kippt.com/api/clips/', $email, $pass, true);
     $hdrsArr['X-Kippt-Username'] = $email;
     $hdrsArr['X-Kippt-API-Token'] = $pass;
     $cnt = wp_remote_get('https://kippt.com/api/lists/', array('timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr));
     $lists = json_decode($cnt['body'], true);
     foreach ($lists['objects'] as $list) {
         if ($list['slug'] == $options['list']) {
             $listID = $list['resource_uri'];
         }
     }
     if (empty($listID)) {
         $listID = '';
     }
     $flds = array();
     $flds['url'] = $message['url'];
     $flds['notes'] = $msg;
     $flds['title'] = $msgT;
     $flds['list'] = $listID;
     $flds = json_encode($flds);
     // prr($flds);
     $cnt = wp_remote_post('https://kippt.com/api/clips/', array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $flds));
     if (is_wp_error($cnt) || empty($cnt['body']) || $cnt['response']['code'] != '201') {
         return "ERROR: " . print_r($cnt, true);
     }
     //prr($cnt['body']);
     //## Return
     if (stripos($cnt['body'], '"resource_uri": "') !== false) {
         $pid = CutFromTo($cnt['body'], '"resource_uri": "', '"');
         $purl = 'https://kippt.com' . CutFromTo($cnt['body'], '"app_url": "', '"');
         return array('postID' => $pid, 'isPosted' => 1, 'postURL' => $purl, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($cnt, true);
         return $badOut;
     }
 }
コード例 #21
0
ファイル: vb.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     global $nxs_vbCkArray;
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['vbUName']) || trim($options['vbPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $pass = substr($options['vbPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['vbPass'], 5)) : $options['vbPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['vbMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['vbMsgTFormat'], $message);
     }
     $urlToGo = !empty($message['url']) ? $message['url'] : '';
     //## Post
     if (isset($options['vbSvC'])) {
         $nxs_vbCkArray = maybe_unserialize($options['vbSvC']);
     }
     $loginError = true;
     if (is_array($nxs_vbCkArray)) {
         $loginError = $this->nxs_doCheckVB($options['vbURL']);
     }
     if ($loginError !== false) {
         $loginError = $this->nxs_doConnectToVB($options['vbUName'], $pass, $options['vbURL']);
     }
     if ($loginError !== false) {
         return "ERROR - BAD USER/PASS - " . print_r($loginError, true);
     }
     $ret = $this->nxs_doPostToVB($options['vbURL'], $msgT, $msg, $urlToGo, $message['tags']);
     if (!is_array($ret) && $ret != 'OK') {
         $badOut['Error'] .= 'Something went wrong - ' . print_r($ret, true);
     } else {
         return array('postID' => $ret['post_id'], 'isPosted' => 1, 'postURL' => $ret['post_id'], 'pDate' => date('Y-m-d H:i:s'));
     }
     return $badOut;
 }
コード例 #22
0
ファイル: pn.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_gCookiesArr;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['pnUName']) || trim($options['pnPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $pass = substr($options['pnPass'], 0, 5) == 'g9c1a' ? nsx_doDecode(substr($options['pnPass'], 5)) : $options['pnPass'];
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['pnMsgFormat'], $message);
     }
     $boardID = $options['pnBoard'];
     // prr($boardID); prr($_POST); die();
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     if ($imgURL == '') {
         $badOut['Error'] .= 'NO Image.';
     }
     $urlToGo = !empty($message['url']) ? $message['url'] : '';
     //## Check for existing session
     if (isset($options['ck'])) {
         $nxs_gCookiesArr = maybe_unserialize($options['ck']);
     }
     $loginError = true;
     if (is_array($nxs_gCookiesArr)) {
         $loginError = doCheckPinterest();
     }
     if ($loginError !== false) {
         $loginError = doConnectToPinterest($options['pnUName'], $pass);
     }
     if ($loginError !== false) {
         $badOut['Error'] = print_r($loginError, true) . " - BAD USER/PASS";
         return $badOut;
     }
     if (preg_match('/\\$(\\d+\\.\\d+)/', $msg, $matches)) {
         $price = $matches[0];
     } else {
         $price = '';
     }
     if (isset($options['cImgURL']) && $options['cImgURL'] == 'S') {
         $urlToGo = nxs_mkShortURL($urlToGo);
     } elseif (isset($options['cImgURL']) && $options['cImgURL'] == 'N') {
         $urlToGo = '';
     }
     $ret = doPostToPinterest($msg, $imgURL, $urlToGo, $boardID, 'TITLE WHERE IS IT?', $price, $urlToGo . "/GTH/");
     if ($ret == 'OK') {
         $ret = array("code" => "OK", "post_id" => '');
     }
     //prr($ret);
     if (is_array($ret) && !empty($ret['post_id'])) {
         return array('postID' => str_ireplace('/pin/', '', $ret['post_id']), 'isPosted' => 1, 'postURL' => $ret['post_url'], 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= 'Something went wrong - ' . print_r($ret, true);
     }
     return $badOut;
 }
コード例 #23
0
ファイル: vk.api.php プロジェクト: voquanghoa/WebPhim
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     global $nxs_vkCkArray;
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     if ((!isset($options['uName']) || trim($options['uPass']) == '') && (!isset($options['vkAppAuthToken']) || trim($options['vkAppAuthToken']) == '')) {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     $urlToGo = !empty($message['url']) ? $message['url'] : '';
     $postType = $options['postType'];
     //$link = urlencode($link); $desc = urlencode(substr($msg, 0, 500));
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $msgOpts = array();
     $msgOpts['uid'] = $options['vkPgID'];
     // if ($link!='') $msgOpts['link'] = $link;
     if (!empty($message['videoURL']) && $postType == "I") {
         $postType = 'A';
         $urlToGo = $message['videoURL'];
         $msgOpts['vID'] = $vids[0];
     }
     if ($postType == 'I' && trim($imgURL) == '') {
         $postType = 'T';
     }
     $msgOpts['type'] = $postType;
     if (function_exists('nxs_doPostToVK') && $postType == 'A' && $urlToGo != '') {
         //## Login
         if (isset($options['vkSvC'])) {
             $nxs_vkCkArray = maybe_unserialize($options['vkSvC']);
         }
         $loginError = true;
         if (is_array($nxs_vkCkArray)) {
             $loginError = nxs_doCheckVK();
         }
         if ($loginError != false) {
             if (!empty($options['vkPh'])) {
                 $replArr = explode(' ... ', $options['vkPhReq']);
                 $ph = $options['vkPh'];
                 $ln = strlen($replArr[0]);
                 if (substr($ph, 0, $ln) == $replArr[0]) {
                     $ph = substr($ph, $ln);
                 }
                 $ln = strlen($replArr[1]);
                 $mln = -$ln;
                 if (substr($ph, $mln) == $replArr[1]) {
                     $ph = substr($ph, $ln, $mln);
                 }
             } else {
                 $ph = '';
             }
             $loginError = nxs_doConnectToVK($options['uName'], $pass, $ph);
         }
         //       prr($loginError);
         if ($loginError !== false) {
             if (stripos($loginError, 'Phone verification required:') !== false) {
                 return $loginError;
             } else {
                 return "ERROR - BAD USER/PASS - " . print_r($loginError, true);
             }
         }
         //## Post
         $msgOpts['url'] = $urlToGo;
         $msgOpts['urlTitle'] = $message['urlTitle'];
         $msgOpts['urlDesc'] = $message['urlDescr'];
         $msgOpts['imgURL'] = $imgURL;
         $ret = nxs_doPostToVK($msg, $options['url'], $msgOpts);
         if (is_array($ret) && !empty($ret['code']) && $ret['code'] == 'OK') {
             return array('postID' => $ret['post_id'], 'isPosted' => 1, 'postURL' => 'http://vk.com/wall' . $ret['post_id'], 'pDate' => date('Y-m-d H:i:s'));
         } else {
             $badOut .= 'ERROR: ' . print_r($ret, true);
         }
     }
     //prr($postType);
     if ($postType == 'I') {
         $imgUpld = $this->nxs_uplImgtoVK($imgURL, $options);
         if (is_object($imgUpld)) {
             $imgID = $imgUpld->id;
             $atts[] = $imgID;
         } else {
             $badOut['Error'] .= '-=ERROR=- ' . print_r($imgUpld, true);
         }
     }
     if ($postType != 'A') {
         if ($options['addBackLink'] == '1') {
             $atts[] = $urlToGo;
         }
         if (is_array($atts)) {
             $atts = implode(',', $atts);
         }
         $postUrl = 'https://api.vkontakte.ru/method/wall.post';
         $postArr = array('owner_id' => $options['pgIntID'], 'access_token' => $options['vkAppAuthToken'], 'from_group' => '1', 'message' => $msg, 'attachment' => $atts);
         $response = wp_remote_post($postUrl, array('body' => $postArr));
         if (is_wp_error($response) || is_object($response) && isset($response->errors) || is_array($response) && stripos($response['body'], '"error":') !== false) {
             $badOut['Error'] .= 'Error: ' . print_r($response['body'], true);
         } else {
             $respJ = json_decode($response['body'], true);
             $ret = $options['pgIntID'] . '_' . $respJ['response']['post_id'];
         }
     }
     if (isset($ret) && $ret != '') {
         return array('postID' => $ret, 'isPosted' => 1, 'postURL' => 'http://vk.com/wall' . $ret, 'pDate' => date('Y-m-d H:i:s'));
     }
     return $badOut;
 }
コード例 #24
0
ファイル: bg.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     // prr($message);  prr($options);
     //## Check API Lib
     //if (!function_exists('doConnectToBlogger')) if (file_exists('apis/postToGooglePlus.php')) require_once ('apis/postToGooglePlus.php'); elseif (file_exists('/home/_shared/deSrc.php')) require_once ('/home/_shared/deSrc.php');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if ((!isset($options['bgUName']) || empty($options['bgPass'])) && empty($options['AccessToken'])) {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['bgMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['bgMsgTFormat'], $message);
     }
     if ($options['bgInclTags'] == '1') {
         $tags = nsTrnc($message['tags'], 195, ',', '');
     } else {
         $tags = '';
     }
     //## Check/Fix HTML
     if (class_exists('DOMDocument')) {
         $doc = new DOMDocument();
         @$doc->loadHTML('<?xml encoding="UTF-8">' . $msg);
         $doc->encoding = 'UTF-8';
         $msg = $doc->saveHTML();
         $msg = CutFromTo($msg, '<body>', '</body>');
         $msg = preg_replace('/<br(.*?)\\/?>/', '<br$1/>', $msg);
         $msg = preg_replace('/<img(.*?)\\/?>/', '<img$1/>', $msg);
         require 'apis/htmlNumTable.php';
         if (is_array($HTML401NamedToNumeric)) {
             $msg = strtr($msg, $HTML401NamedToNumeric);
             $msgT = strtr($msgT, $HTML401NamedToNumeric);
         }
     }
     $msg = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $msg);
     $msg = preg_replace('/<!--(.*)-->/Uis', "", $msg);
     $nxshf = new NXS_HtmlFixer();
     $nxshf->debug = false;
     $msg = $nxshf->getFixedHtml($msg);
     $msg = str_replace("\r\n", "\n", $msg);
     $msg = str_replace("\n\r", "\n", $msg);
     $msg = str_replace("\r", "\n", $msg);
     $msg = str_replace("\n", "<br/>", $msg);
     //## Make Post
     $email = $options['bgUName'];
     $pass = substr($options['bgPass'], 0, 5) == 'b4d7s' ? nsx_doDecode(substr($options['bgPass'], 5)) : $options['bgPass'];
     $blogID = $options['bgBlogID'];
     // prr($msgT); prr($msg); die();
     if (class_exists('nxsAPI_GP') && !empty($options['bgUName']) && empty($options['APIKey'])) {
         $nt = new nxsAPI_GP();
         if (!empty($options['ck'])) {
             $nt->ck = $options['ck'];
         }
         $nt->debug = false;
         $loginError = $nt->connect($email, $pass, 'BG');
         if (!$loginError) {
             $result = $nt->postBG($blogID, $msgT, $msg, $tags);
             // prr($result);
         } else {
             $badOut['Error'] = "Login/Connection Error: " . print_r($loginError, true);
             return $badOut;
         }
         if (is_array($result) && $result['isPosted'] == '1') {
             nxs_save_glbNtwrks('bg', $options['ii'], $nt->ck, 'ck');
         }
         return $result;
     } else {
         //## Refresh token
         if (function_exists('get_option')) {
             $currTime = time() + get_option('gmt_offset') * HOUR_IN_SECONDS;
         } else {
             $currTime = time();
         }
         if ($options['AccessTokenExp'] < $currTime) {
             $tknURL = 'https://www.googleapis.com/oauth2/v3/token?refresh_token=' . $options['RefreshToken'] . '&client_id=' . $options['APIKey'] . '&client_secret=' . $options['APISec'] . '&grant_type=refresh_token';
             $response = wp_remote_post($tknURL);
             $resp = json_decode($response['body'], true);
             $options['AccessToken'] = $resp['access_token'];
             $options['AccessTokenExp'] = $currTime + $resp['expires_in'];
             nxs_save_glbNtwrks('bg', $options['ii'], $resp['access_token'], 'AccessTokenExp');
             nxs_save_glbNtwrks('bg', $options['ii'], $options['AccessTokenExp'], 'AccessTokenExp');
             //nxs_addToLogN('S', 'Test', $logNT, 'Token Refreshed '.date('Y-m-d H:i:s',$options['AccessTokenExp'])."|".$tknURL.$options['AccessToken'].print_r($response, true));
         }
         //## Post
         $post = array("kind" => "blogger#post", "blog" => array("id" => $blogID), "title" => $msgT, "content" => $msg);
         $post = json_encode($post);
         // prr($post);
         $hdrsArr = array('Content-Type' => 'application/json');
         $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'body' => $post);
         $tknURL = 'https://www.googleapis.com/blogger/v3/blogs/' . $blogID . '/posts?access_token=' . $options['AccessToken'] . '';
         $ret = '';
         $response = wp_remote_post($tknURL, $advSet);
         //prr($tknURL); prr($response);
         if (is_object($response) && isset($response->errors)) {
             $badOut['Error'] = print_r($response, true);
         } else {
             $ret = json_decode($response['body'], true);
         }
         //prr($ret);
         if (is_array($ret) && !empty($ret['id'])) {
             return array('postID' => $ret['id'], 'isPosted' => 1, 'postURL' => $ret['url'], 'pDate' => date('Y-m-d H:i:s'));
         } else {
             $badOut['Error'] .= "Error: " . print_r($ret, true);
             return $badOut;
         }
     }
     //## Return
     if (is_array($ret) && $ret['post_id'] != '') {
         return array('postID' => $ret['post_id'], 'isPosted' => 1, 'postURL' => $ret['post_id'], 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($ret, true);
         return $badOut;
     }
 }
コード例 #25
0
ファイル: su.api.php プロジェクト: voquanghoa/WebPhim
 function doPostToNT($options, $message)
 {
     global $nxs_suCkArray;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['suUName']) || trim($options['suPass']) == '') {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     $pass = substr($options['suPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['suPass'], 5)) : $options['suPass'];
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['suMsgFormat'], $message);
     }
     $urlToGo = !empty($message['url']) ? $message['url'] : '';
     $tags = $message['tags'];
     if (isset($options['suSvC'])) {
         $nxs_suCkArray = maybe_unserialize($options['suSvC']);
     }
     $loginError = true;
     if (is_array($nxs_suCkArray)) {
         $loginError = $this->nxs_doCheckSU();
     }
     if ($loginError != false) {
         $loginError = $this->nxs_doConnectToSU($options['suUName'], $pass);
     }
     if ($loginError !== false) {
         $badOut['Error'] = print_r($loginError, true) . " - BAD USER/PASS";
         return $badOut;
     }
     $ret = $this->nxs_doPostToSU($msg, $urlToGo, $options['suCat'], $tags, $options['nsfw'] == '1');
     // $extInfo .= "++".$msg."|".$link."|".$options['suCat']."|".$tags."|".$options['nsfw'];
     if ($ret == 'OK') {
         $ret = array("code" => "OK", "post_id" => '');
     }
     if (!is_array($ret) && $ret != 'OK') {
         $badOut['Error'] .= 'Something went wrong - ' . print_r($ret, true);
     } elseif (isset($ret['code']) && $ret['code'] == 'OK') {
         return array('isPosted' => '1', 'postID' => $ret['post_id'], 'postURL' => 'http://www.stumbleupon.com/content/' . $ret['post_id'] . '/comments', 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= 'Error - ' . print_r($ret, true);
     }
     return $badOut;
 }
コード例 #26
0
 function doPostToNT($options, $message)
 {
     $badOut = array('postID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     $liPostID = '';
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if ((!isset($options['ulName']) || trim($options['uPass']) == '') && empty($options['liOAuthVerifier'])) {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     if (empty($options['liMsgFormatT'])) {
         $options['liMsgFormatT'] = '%TITLE%';
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['liMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['liMsgFormatT'], $message);
     }
     if (empty($options['postType'])) {
         if ((int) $options['liAttch'] == 1 || $isNew) {
             $options['postType'] = 'A';
         }
     }
     if ($options['postType'] == 'A' || $options['postType'] == 'I') {
         if (isset($message['imageURL'])) {
             $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
         } else {
             $imgURL = '';
         }
         if (preg_match("/noImg.\\.png/i", $imgURL)) {
             $imgURL = '';
         }
         if (!empty($message['urlDescr'])) {
             $dsc = $message['urlDescr'];
         } else {
             $dsc = $msg;
         }
         $dsc = strip_tags($dsc);
         $dsc = nxs_decodeEntitiesFull($dsc);
         $dsc = nxs_html_to_utf8($dsc);
         $dsc = nsTrnc($dsc, 300);
     }
     $msg = strip_tags($msg);
     $msg = nxs_html_to_utf8($msg);
     $msgT = nxs_html_to_utf8($msgT);
     $urlToGo = $message['url'];
     if (function_exists("doConnectToLinkedIn") && $options['ulName'] != '' && $options['uPass'] != '') {
         $dusername = $options['ulName'];
         $pass = substr($options['uPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['uPass'], 5)) : $options['uPass'];
         // ??? Do we need that??????
         $auth = doConnectToLinkedIn($options['ulName'], $options['uPass'], $options['ii']);
         if ($auth != false) {
             $badOut['Error'] .= "|Auth Error - " . $auth;
             return $badOut;
         }
         $to = $options['uPage'] != '' ? $options['uPage'] : 'https://www.linkedin.com/home';
         $lnk = array();
         $msg = str_ireplace('&nbsp;', ' ', $msg);
         $msg = nsTrnc(strip_tags($msg), 700);
         $lnk['postTitle'] = $msgT;
         if ($options['postType'] == 'A') {
             $lnk['title'] = $message['urlTitle'];
             $lnk['desc'] = $message['urlDescr'];
             $lnk['url'] = $urlToGo;
             $lnk['img'] = $imgURL;
             $lnk['postType'] = 'A';
         }
         if ($options['postType'] == 'I') {
             $lnk['title'] = '';
             $lnk['desc'] = '';
             $lnk['url'] = $imgURL;
             $lnk['img'] = $imgURL;
             $lnk['postType'] = 'I';
             $lnk['postTitle'] = $msgT;
         }
         if ($options['postType'] == 'T') {
             $lnk['postType'] = 'T';
         }
         global $nxs_gCookiesArr;
         $li = new nxsAPI_LI();
         $li->debug = false;
         if (!empty($nxs_gCookiesArr)) {
             $li->ck = $nxs_gCookiesArr;
         }
         $ret = $li->post($msg, $lnk, $to);
         if (is_array($ret) && !empty($ret['isPosted'])) {
             return $ret;
         }
         $liPostID = $options['uPage'];
     } else {
         if (!empty($options['isV2'])) {
             //## V2
             if ($options['grpID'] != '') {
                 try {
                     if ($msgT == '') {
                         $msgT = ' ';
                     }
                     if ($options['postType'] == 'A') {
                         $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID'], str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc);
                     } else {
                         $ret = $this->postToGroup($options['liAccessToken'], $msg, $msgT, $options['grpID']);
                     }
                     $liPostID = 'http://www.linkedin.com/groups?gid=' . $options['grpID'];
                 } catch (Exception $o) {
                     $ret = "ERROR: " . print_r($o, true);
                 }
             } else {
                 //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc;
                 if ($options['postType'] == 'A') {
                     $ret = $this->postShare($options['liAccessToken'], $msg, nsTrnc($msgT, 200), str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc);
                 } else {
                     $ret = $this->postShare($options['liAccessToken'], $msg);
                 }
             }
         } else {
             //## V1
             require_once 'apis/liOAuth.php';
             $linkedin = new nsx_LinkedIn($options['liAPIKey'], $options['liAPISec']);
             $linkedin->oauth_verifier = $options['liOAuthVerifier'];
             $linkedin->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
             $linkedin->access_token = new nsx_trOAuthConsumer($options['liAccessToken'], $options['liAccessTokenSecret'], 1);
             $msg = nsTrnc($msg, 700);
             //prr($urlToGo);  $urlToGo = urlencode($urlToGo);   prr($urlToGo); die();
             if ($options['grpID'] != '') {
                 try {
                     if ($msgT == '') {
                         $msgT = ' ';
                     }
                     if ($options['postType'] == 'A') {
                         $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID'], str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc);
                     } else {
                         $ret = $linkedin->postToGroup($msg, $msgT, $options['grpID']);
                     }
                     $liPostID = 'http://www.linkedin.com/groups?gid=' . $options['grpID'];
                     if ($ret == '201') {
                         $ret = array('updateUrl' => $liPostID);
                     }
                 } catch (Exception $o) {
                     $ret = "ERROR: " . print_r($o, true);
                 }
             } else {
                 //echo $msg ."|". nsTrnc($msgT, 200) ."|". $urlToGo ."|". $imgURL ."|". $dsc;
                 try {
                     if ($options['postType'] == 'A') {
                         $ret = $linkedin->postShare($msg, nsTrnc($msgT, 200), str_replace('&', '&amp;', $urlToGo), $imgURL, $dsc);
                     } else {
                         $ret = $linkedin->postShare($msg);
                     }
                 } catch (Exception $o) {
                     $ret = "ERROR:" . print_r($o, true);
                 }
             }
         }
         if ($liPostID == '') {
             $liPostID = $options['liUserInfo'];
         }
     }
     // prr($ret);
     if (!is_array($ret) && stripos($ret, '<update-url>') !== false) {
         $rurl = CutFromTo($ret, '<update-url>', '</update-url>');
         $ret = array('updateUrl' => $rurl);
     }
     if (is_array($ret) && !empty($ret['updateUrl'])) {
         if (stripos($ret['updateUrl'], 'topic=') !== false) {
             $liPostID = CutFromTo($ret['updateUrl'], 'topic=', '&');
         } else {
             $liPostID = '';
         }
         return array('isPosted' => '1', 'postID' => $liPostID, 'postURL' => $ret['updateUrl'], 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($ret, true);
     }
     return $badOut;
 }
コード例 #27
0
ファイル: rd.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['rdUName']) || trim($options['rdUName']) == '' || !isset($options['rdPass']) || trim($options['rdPass']) == '') {
         $badOut['Error'] = 'No username/password Found';
         return $badOut;
     }
     //## Format Post
     if (!empty($message['pTitle'])) {
         $title = $message['pTitle'];
     } else {
         $title = nxs_doFormatMsg($options['rdTitleFormat'], $message);
     }
     $title = nsTrnc($title, 300);
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['rdTextFormat'], $message);
     }
     //## Make Post
     $pass = substr($options['rdPass'], 0, 5) == 'n5g9a' ? nsx_doDecode(substr($options['rdPass'], 5)) : $options['rdPass'];
     $hdrsArr = '';
     $loginInfo = doConnectToRD($options['rdUName'], $pass);
     if (!is_array($loginInfo)) {
         $badOut['Error'] = print_r($loginInfo, true) . " - ERROR";
         return $badOut;
     }
     $mh = $loginInfo['mh'];
     $ck = $loginInfo['ck'];
     $post = array('uh' => $mh, 'sr' => $options['rdSubReddit'], 'title' => $title, 'save' => true);
     if ($options['postType'] == 'A') {
         $post['url'] = $message['url'];
         $post['kind'] = 'link';
         $retNum = 16;
     } else {
         $post['text'] = $text;
         $post['kind'] = 'self';
         $retNum = 10;
     }
     $url = "http://www.reddit.com/api/submit";
     $postParams = array('method' => 'POST', 'timeout' => 45, 'redirection' => 0, 'extension' => 'json', 'headers' => $hdrsArr, 'body' => $post, 'cookies' => $ck);
     $response = wp_remote_post($url, $postParams);
     // prr($postParams); prr($response);
     if (is_wp_error($response)) {
         $badOut['Error'] = print_r($response, true) . " - ERROR";
         return $badOut;
     }
     $response = json_decode($response['body'], true);
     $rdNewPostID = 'http://www.reddit.com';
     // prr($response);
     if (!isset($response['jquery']) || !is_array($response['jquery'])) {
         $badOut['Error'] = print_r($response, true) . " - ERROR";
         return $badOut;
     }
     $r = $response['jquery'];
     if (is_array($r[$retNum][3]) && count($r[$retNum][3]) > 0 && stripos($r[$retNum][3][0], 'http://') !== false) {
         $rdNewPostID = $r[$retNum][3][0];
     }
     if (isset($r[18]) && is_array($r[18][3]) && count($r[18][3]) > 0 && stripos($r[18][3][0], 'error.BAD_CAPTCHA') !== false) {
         $badOut['Error'] = "ERROR: Post Rejected. Reddit thinks that you don't have rights to post here";
         return $badOut;
     }
     if (isset($r[18]) && is_array($r[18][3]) && count($r[18][3]) > 0 && stripos($r[18][3][0], 'error') !== false) {
         $badOut['Error'] = "ERROR: " . $r[18][3][0];
         return $badOut;
     }
     if (is_array($r[$retNum][3]) && count($r[$retNum][3]) > 0 && stripos($r[$retNum][3][0], 'http://') === false) {
         $badOut['Error'] = print_r($r[$retNum][3][0], true) . " - ERROR";
         return $badOut;
     }
     if (isset($r[18]) && is_array($r[18][3]) && count($r[18][3]) > 0 && stripos($r[18][3][0], 'already been submitted') !== false) {
         $rdNewPostID .= str_ireplace('?already_submitted=true', '', $r[10][3][0]);
     }
     // echo "ID:".$rdNewPostID;
     if ($rdNewPostID != 'http://www.reddit.com') {
         return array('postID' => $rdNewPostID, 'isPosted' => 1, 'postURL' => $rdNewPostID, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($tmhOAuth->response['response'], true) . " MSG:" . print_r($msg, true);
         return $badOut;
     }
     return $badOut;
 }
コード例 #28
0
ファイル: tr.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['trConsKey']) || trim($options['trConsSec']) == '' || empty($options['trAccessTocken'])) {
         $badOut['Error'] = 'Not Configured';
         return $badOut;
     }
     if (!isset($options['postType']) && isset($options['trPostType'])) {
         $options['postType'] = $options['trPostType'];
     }
     //## Compatibility with v <3.2
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     if (empty($message['postDate'])) {
         $message['postDate'] = '';
     }
     if (empty($options['trMsgTFormat'])) {
         $options['trMsgTFormat'] = '%TITLE%';
     }
     //## Format
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['trMsgFormat'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['trMsgTFormat'], $message);
     }
     //## Post
     $options['trURL'] = trim(str_ireplace('http://', '', $options['trURL']));
     if (substr($options['trURL'], -1) == '/') {
         $options['trURL'] = substr($options['trURL'], 0, -1);
     }
     require_once 'apis/trOAuth.php';
     $consumer_key = $options['trConsKey'];
     $consumer_secret = $options['trConsSec'];
     $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $options['trAccessTocken']['oauth_token'], $options['trAccessTocken']['oauth_token_secret']);
     //prr($options);
     $postArr = array('tags' => $message['tags'], 'date' => $message['postDate']);
     if ($options['fillSrcURL'] == '1') {
         $postArr['source_url'] = $message['url'];
     }
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     // postType
     if ($options['postType'] == 'I') {
         $postArr['type'] = 'photo';
         $postArr['caption'] = $msg;
         $postArr['source'] = $imgURL;
         if (!isset($options['cImgURL']) || $options['cImgURL'] == '' || $options['cImgURL'] == 'R') {
             $postArr['link'] = $message['url'];
         } elseif ($options['cImgURL'] == 'S') {
             $postArr['link'] = $message['url'];
             $postArr['link'] = nxs_mkShortURL($postArr['link']);
         }
     } elseif ($options['postType'] == 'U') {
         $postArr['type'] = 'audio';
         $postArr['caption'] = $msg;
         $postArr['external_url'] = $aUrl;
     } elseif ($options['postType'] == 'V') {
         $postArr['type'] = 'video';
         $postArr['caption'] = $msg;
         $embedTxt = '<iframe width="560" height="315" src="http://www.youtube.com/embed/' . $message['videoURL'] . '" frameborder="0" allowfullscreen></iframe>';
         $postArr['embed'] = $embedTxt;
     } else {
         $postArr['title'] = $msgT;
         $postArr['type'] = 'text';
         $postArr['source'] = $message['url'];
         $postArr['body'] = $msg;
     }
     $postinfo = $tum_oauth->post("http://api.tumblr.com/v2/blog/" . $options['trURL'] . "/post", $postArr);
     // prr("http://api.tumblr.com/v2/blog/".$options['trURL']."/post");  prr($postinfo);  prr($postArr);
     $code = $postinfo->meta->status;
     // echo "XX".print_r($code);  prr($postinfo); // prr($msg); prr($postinfo); echo $code."VVVV"; die("|====");
     if ($code == 201) {
         return array('postID' => $postinfo->response->id, 'isPosted' => 1, 'postURL' => 'http://' . $options['trURL'] . "/post/" . $postinfo->response->id, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= $code . " - " . $postinfo->meta->msg . (isset($postinfo->errmsg) ? $postinfo->errmsg : '') . " | " . print_r($postinfo, true);
     }
     return $badOut;
 }
コード例 #29
0
ファイル: tw.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     if (!function_exists('nxs_remote_get') && function_exists('wp_remote_get')) {
         function nxs_remote_get($url)
         {
             return wp_remote_get($url);
         }
     }
     if (!function_exists('is_nxs_error') && function_exists('is_wp_error')) {
         function is_nxs_error($a)
         {
             return is_wp_error($a);
         }
     }
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['twAccToken']) || trim($options['twAccToken']) == '') {
         $badOut['Error'] = 'No Auth Token Found';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Old Settings Fix
     if ($options['attchImg'] == '1') {
         $options['attchImg'] = 'large';
     }
     if ($options['attchImg'] == '0') {
         $options['attchImg'] = false;
     }
     if (isset($message['img']) && is_string($message['img'])) {
         $img = trim($message['img']);
     } else {
         $img = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['twMsgFormat'], $message);
     }
     if ($options['attchImg'] != false) {
         if (isset($message['imageURL'])) {
             $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
         } else {
             $imgURL = '';
         }
     }
     if (empty($imgURL) && $img == '') {
         $options['attchImg'] = false;
     }
     //## Make Post
     //$options['attchImg']='1'; $imgURL = 'http://ecx.images-amazon.com/images/I/41caE5Uc5ML._AA160_.jpg';
     $hdrsArr['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0';
     $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'sslverify' => false);
     //$msg = $message['message']; $imgURL = trim($message['imageURL']); $img = trim($message['img']); $nxs_urlLen = $message['urlLength'];
     if ($options['attchImg'] != false && $img == '' && $imgURL != '') {
         $imgURL = str_replace(' ', '%20', $imgURL);
         if (ini_get('allow_url_fopen')) {
             if (getimagesize($imgURL) !== false) {
                 $img = nxs_remote_get($imgURL, $advSet);
                 if (is_nxs_error($img)) {
                     $options['attchImg'] = false;
                 } else {
                     $img = $img['body'];
                 }
             } else {
                 $options['attchImg'] = false;
             }
         } else {
             $img = nxs_remote_get($imgURL, $advSet);
             if (is_nxs_error($img)) {
                 $options['attchImg'] = false;
             } elseif (isset($img['body']) && trim($img['body']) != '') {
                 $img = $img['body'];
             } else {
                 $options['attchImg'] = false;
             }
         }
     }
     if ($options['attchImg'] != false && $img != '') {
         $twLim = 118;
     } else {
         $twLim = 140;
     }
     require_once 'apis/tmhOAuth.php';
     if ($nxs_urlLen > 0) {
         $msg = nsTrnc($msg, $twLim - 22 + $nxs_urlLen);
     } else {
         $msg = nsTrnc($msg, $twLim);
     }
     //prr($msg); die('TTWWW');
     if (substr($msg, 0, 1) == '@') {
         $msg = ' ' . $msg;
     }
     //prr(urlencode($msg));  $msg = html_entity_decode($msg);  prr(urlencode($msg));   die();
     $tmhOAuth = new NXS_tmhOAuth(array('consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec']));
     if ($options['attchImg'] != false && $img != '') {
         $params_array = array('media[]' => $img, 'status' => $msg);
     } else {
         $params_array = array('status' => $msg);
     }
     if (!empty($options['in_reply_to_id'])) {
         $params_array['in_reply_to_status_id'] = $options['in_reply_to_id'];
     }
     if ($options['attchImg'] != false && $img != '') {
         $code = $tmhOAuth->request('POST', 'https://api.twitter.com/1.1/statuses/update_with_media.json', $params_array, true, true);
     } else {
         $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), $params_array);
     }
     //prr($msg);
     if ($code == '403' && stripos($tmhOAuth->response['response'], 'User is over daily photo limit') !== false && $options['attchImg'] != false && $img != '') {
         $badOut['Error'] .= "User is over daily photo limit. Will post without image\r\n";
         $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' => $msg));
     }
     if ($code == 200) {
         $twResp = json_decode($tmhOAuth->response['response'], true);
         if (is_array($twResp) && isset($twResp['id_str'])) {
             $twNewPostID = $twResp['id_str'];
         }
         if (is_array($twResp) && isset($twResp['user'])) {
             $twPageID = $twResp['user']['screen_name'];
         }
         return array('postID' => $twNewPostID, 'isPosted' => 1, 'postURL' => 'https://twitter.com/' . $twPageID . '/status/' . $twNewPostID, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= "Resp: " . print_r($tmhOAuth->response['response'], true) . "| Error: " . print_r($tmhOAuth->response['error'], true) . "| MSG: " . print_r($msg, true);
         return $badOut;
     }
     return $badOut;
 }
コード例 #30
0
ファイル: sc.api.php プロジェクト: digideskio/stammtisch
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['accessToken']) || trim($options['accessToken']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $postType = $options['postType'];
     require_once 'apis/scOAuth.php';
     $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
     $tiID = $tum_oauth->makeReq('http://www.scoop.it/api/1/topic', array('urlName' => $options['topicURL']));
     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;
     }
     $postArr = array('action' => 'create', 'title' => $msgT, 'content' => $text, 'url' => $postType == 'A' ? $message['url'] : '', 'imageUrl' => ($postType == 'I' || $postType == 'A') && !empty($imgURL) ? $imgURL : '', 'topicId' => $tiID);
     $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST');
     // prr($postinfo);
     if (is_array($postinfo) && isset($postinfo['post'])) {
         $apNewPostID = $postinfo['post']['id'];
         $apNewPostURL = $postinfo['post']['scoopUrl'];
         if ($options['inclTags'] == '1') {
             $postArr = array('action' => 'edit', 'tag' => $message['tags'], 'id' => $apNewPostID);
             $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST');
         }
     }
     $code = $tum_oauth->http_code;
     if (!empty($apNewPostID)) {
         return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($postinfo, true) . " Code:" . $tum_oauth->http_code;
         return $badOut;
     }
     return $badOut;
 }