예제 #1
0
 function check()
 {
     $ck = $this->ck;
     if (!empty($ck) && is_array($ck)) {
         $hdrsArr = $this->headers('https://www.deviantart.com');
         if ($this->debug) {
             echo "[DA] Checking....;<br/>\r\n";
         }
         $rep = nxs_remote_get('https://www.deviantart.com', array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck));
         if (is_wp_error($rep)) {
             $badOut = print_r($rep, true) . " - ERROR https://www.deviantart.com is not accessible. ";
             return $badOut;
         }
         $ck2 = $rep['cookies'];
         for ($i = 0; $i < count($ck); $i++) {
             if ($ck[$i]->name == 'userinfo') {
                 $ck[$i]->value = urlencode($ck2[0]->value);
             }
         }
         $this->ck = $ck;
         if (is_nxs_error($rep)) {
             return false;
         }
         $contents = $rep['body'];
         //if ($this->debug) prr($contents);
         $mh = CutFromTo($rep['body'], '$(\'#logoutme\').submit();">', 'data-ga_click_event');
         $mh = CutFromTo($mh, 'href="', '"');
         $this->mh = $mh;
         return stripos($contents, 'https://www.deviantart.com/users/logout') !== false;
     } else {
         return false;
     }
 }
function nxs_CptCheckGP($o)
{
    session_id("nxs-temp-gpcpt");
    session_start();
    $sess = unserialize($_SESSION['nxs-temp-gpcpt']);
    if (!empty($_POST['c'])) {
        $ck = $sess['c'];
        $flds = $sess['f'];
        $flds['recaptcha_response_field'] = $_POST['c'];
        $liObj = new nxsAPI_GP();
        $hdrsArr = $liObj->headers('https://www.youtube.com/', 'https://www.youtube.com', 'POST', false);
        $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds);
        prr($advSet);
        $rep = nxs_remote_post('https://www.youtube.com/das_captcha', $advSet);
        if (is_nxs_error($rep)) {
            $badOut = print_r($rep, true) . " - ERROR";
            return $badOut;
        }
        $contents2 = $rep['body'];
        prr($rep);
        if (stripos($contents2, 'id="error-box"') !== false) {
            echo 'The verification code was invalid or has timed out. Please try again.';
            die;
        }
        if (stripos($contents2, 'The verification code was invalid') !== false) {
            echo 'The verification code was invalid or has timed out. Please try again.';
            die;
        }
        if ($rep['response']['code'] == '303' && !empty($rep['headers']['location'])) {
            echo "OK. You are In";
            $hdrsArr = $liObj->headers('http://www.youtube.com', 'https://www.youtube.com');
            $ck = $rep['cookies'];
            $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck);
            // prr($advSet);
            $rep = nxs_remote_get($rep['headers']['location'], $advSet);
            prr($ck);
            if (is_nxs_error($rep)) {
                $badOut = print_r($rep, true) . " - ERROR";
                return $badOut;
            }
            $ck = $rep['cookies'];
        }
    }
}
예제 #3
0
 function nxsCptCheck_ajax()
 {
     global $nxs_gCookiesArr;
     $advSettings = array();
     if (!empty($_POST['c'])) {
         $seForDB = get_option('nxs_li_ctp_save');
         $ser = maybe_unserialize($seForDB);
         $nxs_gCookiesArr = $ser['c'];
         $ck = $nxs_gCookiesArr;
         $flds = $ser['f'];
         $flds['recaptcha_response_field'] = $_POST['c'];
         $liObj = new nxsAPI_LI();
         $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', false);
         $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds);
         // prr($advSet);
         $rep = nxs_remote_post('https://www.linkedin.com/uas/captcha-submit', $advSet);
         if (is_nxs_error($rep)) {
             $badOut = print_r($rep, true) . " - ERROR";
             return $badOut;
         }
         $contents2 = $rep['body'];
         if (stripos($contents2, '<span class="error">') !== false) {
             echo strip_tags(CutFromTo($contents2, '<span class="error">', '</span>'));
             die;
         }
         if (stripos($contents2, '<div id="global-error">') !== false) {
             echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>');
             die;
         }
         if (stripos($contents2, 'The email address or password you provided does not match our records') !== false) {
             echo "Invalid Login/Password";
             die;
         }
         if (stripos($contents2, 'Hmm, ') !== false) {
             echo "Invalid Login/Password";
             die;
         }
         if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/captcha-submit') !== false) {
             echo "Wrong Captcha. Please try Again";
         }
         if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome') !== false || stripos($rep['headers']['location'], 'linkedin.com/home') !== false)) {
             echo "OK. You are In";
             $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com');
             $ck = $rep['cookies'];
             $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck);
             // prr($advSet);
             $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet);
             if (is_nxs_error($rep)) {
                 $badOut = print_r($rep, true) . " - ERROR";
                 return $badOut;
             }
             $ck = $rep['cookies'];
             if ($_POST['i'] != '') {
                 global $plgn_NS_SNAutoPoster;
                 if (!isset($plgn_NS_SNAutoPoster)) {
                     return;
                 }
                 $options = $plgn_NS_SNAutoPoster->nxs_options;
                 $options['li'][$_POST['i']]['ck'] = $ck;
                 if (is_array($options)) {
                     update_option('NS_SNAutoPoster', $options);
                 }
             }
         }
     }
     if (!empty($_POST['s'])) {
         $seForDB = get_option('nxs_li_ctp_save');
         $ser = maybe_unserialize($seForDB);
         $ck = $ser['c'];
         $flds = $ser['f'];
         $flds['PinVerificationForm_pinParam'] = $_POST['s'];
         $liObj = new nxsAPI_LI();
         $hdrsArr = $liObj->headers('https://www.linkedin.com/uas/login-submit', 'https://www.linkedin.com', 'POST', true);
         $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds);
         // prr($advSet);
         $rep = nxs_remote_post('https://www.linkedin.com/uas/ato-pin-challenge-submit', $advSet);
         if (is_nxs_error($rep)) {
             $badOut = print_r($rep, true) . " - ERROR";
             return $badOut;
         }
         $contents2 = $rep['body'];
         // prr($rep);
         if (stripos($contents2, 'The email address or password you provided does not match our records') !== false) {
             echo "Invalid Login/Password";
             die;
         }
         if (stripos($contents2, '<div id="global-error">') !== false) {
             echo CutFromTo($contents2, '<div role="alert" class="alert error">', '</div>');
             die;
         }
         if (stripos($contents2, 'Hmm, ') !== false) {
             echo "Invalid Login/Password";
             die;
         }
         if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && stripos($rep['headers']['location'], 'linkedin.com/uas/ato-pin-challenge-submit') !== false) {
             echo "Wrong Code. Please try Again";
         }
         if ($rep['response']['code'] == '302' && !empty($rep['headers']['location']) && (stripos($rep['headers']['location'], 'linkedin.com/nhome') !== false || stripos($rep['headers']['location'], 'linkedin.com/home') !== false)) {
             echo "OK. You are In";
         }
         $hdrsArr = $liObj->headers('http://www.linkedin.com/home', 'https://www.linkedin.com');
         $ck = $rep['cookies'];
         $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck);
         // prr($advSet);
         $rep = nxs_remote_get('http://www.linkedin.com/profile/edit?trk=tab_pro', $advSet);
         if (is_nxs_error($rep)) {
             $badOut = print_r($rep, true) . " - ERROR";
             return $badOut;
         }
         $ck = $rep['cookies'];
         if ($_POST['i'] != '') {
             global $plgn_NS_SNAutoPoster;
             if (!isset($plgn_NS_SNAutoPoster)) {
                 return;
             }
             $options = $plgn_NS_SNAutoPoster->nxs_options;
             $options['li'][$_POST['i']]['ck'] = $ck;
             if (is_array($options)) {
                 update_option('NS_SNAutoPoster', $options);
             }
         }
     }
     die;
 }
예제 #4
0
 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;
 }
예제 #5
0
 function post($post)
 {
     $ck = $this->ck;
     $sslverify = false;
     $oneTime = '0R4qFyHCMAYYclyZQFNYrOkq4uy4mN5';
     $enText = nxs_AesCtr::encrypt($post['text'], $oneTime, 256);
     $blogID = '';
     $hdrsArr = $this->headers('http://sett.com/');
     $rep = nxs_remote_get('http://sett.com/' . $post['toURL'], array('headers' => $hdrsArr, 'timeout' => 45, 'cookies' => $ck, 'httpversion' => '1.1', 'sslverify' => $sslverify));
     if (is_nxs_error($rep)) {
         $badOut = "ERROR (Blog URL): " . print_r($rep, true);
         return $badOut;
     }
     $content = $rep['body'];
     if (stripos($content, 'window.site_id =') !== false) {
         $blogID = trim(CutFromTo($content, 'window.site_id =', ';'));
     }
     if (empty($blogID)) {
         return "ERROR (NO Blog ID found): ";
     }
     //if ($_GET('page')=='NextScripts_SNAP.php') prr($admURL);
     $hdrsArr = $this->headers('http://sett.com', 'http://sett.com', 'POST');
     $flds = array('text' => $enText);
     $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'sslverify' => $sslverify, 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds);
     //prr($advSet);
     $rep = nxs_remote_post('http://sett.com/storetext.php', $advSet);
     if (is_nxs_error($rep)) {
         $badOut = "ERROR (Post Post):" . print_r($rep, true);
         return $badOut;
     }
     if (stripos($rep['body'], '{"id":') !== false) {
         $textPush = json_decode($rep['body'], true);
     } else {
         $badOut = "ERROR (Post Post):" . print_r($rep, true);
         return $badOut;
     }
     $pURL = 'https://sett.com/newpost.php?autosave=0&context=&is_html=&offset=&one_time=&parent_uid=&promote=&site=&submit_visible=1&to=&uid=&title=' . urlencode($post['title']) . '&url=' . $this->makeSlug($post['title']) . '&category=&allow_comments=1&allow_promoting=1&allow_indexing=1&subscribe=1&context=false&is_html=false&offset=-4&parent_uid=&promote=1&site_id=' . $blogID . '&type=post&uid=&one_time=' . $oneTime . '&text_id=' . $textPush['id'] . '&text_hash=' . $textPush['hash'];
     $ck = nxsClnCookies($ck);
     $hdrsArr = $this->headers('http://sett.com/' . $post['toURL']);
     $rep = nxs_remote_get($pURL, array('headers' => $hdrsArr, 'timeout' => 45, 'cookies' => $ck, 'httpversion' => '1.1', 'sslverify' => $sslverify));
     if (is_nxs_error($rep)) {
         $badOut = "ERROR (Post Info): " . print_r($rep, true);
         return $badOut;
     }
     if ($rep['response']['code'] == '200') {
         $content = $rep['body'];
         if (stripos($content, '{"errors":[') !== false) {
             $loginArr = json_decode($content, true);
             $err = $loginArr['errors'][0]['title'];
             return "Error: " . $err . " | \r\n<br/>\r\n" . print_r($loginArr, true);
         }
     }
     if (stripos($rep['body'], '{"uid":') !== false) {
         $content = json_decode($rep['body'], true);
         return array('isPosted' => '1', 'postID' => $content['uid'], 'postURL' => 'http://sett.com/' . $post['toURL'] . "/" . $content['uid'], 'pDate' => date('Y-m-d H:i:s'));
     }
     return 'Error: ' . print_r($rep, true);
 }
 function getBoards() { if (!$this->check()){ if ($this->debug) echo "[PN] NO Saved Data;<br/>\r\n"; return 'Not logged IN';} $boards = ''; $ck = $this->ck; $apVer = $this->apVer; $brdsArr = array();
     $iu = 'http://memory.loc.gov/award/ndfa/ndfahult/c200/c240r.jpg'; $su = '/pin/find/?url='.urlencode($iu); $iuu = urlencode($iu); $hdrsArr = $this->headers('http://www.pinterest.com/','','JSON', true);         
     $hdrsArr['X-NEW-APP']='1'; $hdrsArr['X-APP-VERSION']=$apVer; $hdrsArr['X-Pinterest-AppState']='active'; $hdrsArr['Accept'] = 'application/json, text/javascript, */*; q=0.01';                
     $brdURL = 'https://www.pinterest.com/resource/BoardPickerBoardsResource/get/?source_url=%2Fpin%2Ffind%2F%3Furl%'.$iuu.'&data=%7B%22options%22%3A%7B%22filter%22%3A%22all%22%2C%22field_set_key%22%3A%22board_picker%22%7D%2C%22context%22%3A%7B%7D%7D&module_path=App()%3EImagesFeedPage(resource%3DFindPinImagesResource(url%'.$iuu.'))%3EGrid()%3EGridItems()%3EPinnable()%3EShowModalButton(module%3DPinCreate)';$advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck); $rep = nxs_remote_get($brdURL, $advSet);
     if (is_nxs_error($rep)) {  $badOut = print_r($rep, true)." - ERROR"; return $badOut; } $ck = $rep['cookies']; $contents = $rep['body'];   $k = json_decode($contents, true);         
     if (!empty($k['resource_data_cache'])) { $brdsA = $k['resource_data_cache'];
       foreach ($brdsA as $ab) if (!empty($ab) && !empty($ab['data']['all_boards'])) { $ba = $ab['data']['all_boards']; 
         foreach ($ba as $kh) { $boards .= '<option value="'.$kh['id'].'">'.$kh['name'].'</option>'; $brdsArr[] = array('id'=>$kh['id'], 'n'=>$kh['name']); } $this->boards = $brdsArr; return $boards; 
       } 
     } return getBoardsOLD(); //## Remove it in couple months
 }
 function postYT($msg, $ytUrl, $vURL = '', $ytGPPageID='') { $ck = $this->ck; $sslverify = false; 
   $ytUrl = str_ireplace('/feed','',$ytUrl); if (substr($ytUrl, -1)=='/') $ytUrl = substr($ytUrl, 0, -1); $ytUrl .= '/feed'; $hdrsArr = $this->headers('http://www.youtube.com/');
   if ($ytGPPageID!=''){ $pgURL = 'https://www.youtube.com/signin?authuser=0&action_handle_signin=true&pageid='.$ytGPPageID;      if ($this->debug) echo "[YT] G SW to page: ".$ytGPPageID."<br/>\r\n";
     $rep = nxs_remote_get($pgURL, array('headers' => $hdrsArr, 'httpversion' => '1.1', 'redirection' => 0, 'cookies' => $ck, 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) return "ERROR: ".print_r($rep, true);
     if (!empty($rep['cookies'])) foreach ($rep['cookies'] as $ccN) { $fdn = false; foreach ($ck as $ci=>$cc) if ($ccN->name == $cc->name) { $fdn = true; $ck[$ci] = $ccN;  } if (!$fdn) $ck[] = $ccN; }       
   } $rep = nxs_remote_get($ytUrl, array('headers' => $hdrsArr, 'httpversion' => '1.1', 'redirection' => 0, 'cookies' => $ck, 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) return "ERROR: ".print_r($rep, true);
   //## Merge CK
   if (!empty($rep['cookies'])) foreach ($rep['cookies'] as $ccN) { $fdn = false; foreach ($ck as $ci=>$cc) if ($ccN->name == $cc->name) { $fdn = true; $ck[$ci] = $ccN;  } if (!$fdn) $ck[] = $ccN; }      
   $contents = $rep['body']; $gpPageMsg = "Either BAD YouTube USER/PASS or you are trying to post from the wrong account/page. Make sure you have Google+ page ID if your YouTube account belongs to the page.";
   $actFormCode = 'channel_ajax'; if (stripos($contents, 'action="/c4_feed_ajax?')!==false) $actFormCode = 'c4_feed_ajax';
   if (stripos($contents, 'action="/'.$actFormCode.'?')) $frmData = CutFromTo($contents, 'action="/'.$actFormCode.'?', '</form>'); else { 
     if (stripos($contents, 'property="og:url"')) {  $ytUrl = CutFromTo($contents, 'property="og:url" content="', '"').'/feed'; 
       $rep = nxs_remote_get($ytUrl, array('headers' => $hdrsArr, 'httpversion' => '1.1', 'cookies' => $ck, 'sslverify'=>$sslverify)); if (is_nxs_error($rep)) return "ERROR: ".print_r($rep, true); if (!empty($rep['cookies'])) $ck = $rep['cookies'];  $contents = $rep['body'];        
       if (stripos($contents, 'action="/'.$actFormCode.'?')) $frmData = CutFromTo($contents, 'action="/'.$actFormCode.'?', '</form>'); else return 'OG - Form not found. - '. $gpPageMsg;
     } else { $eMsg = "No Form/No OG - ". $gpPageMsg; return $eMsg; }
   }      
   $md = array(); $flds = array(); if ($vURL!='' && stripos($vURL, 'http')===false) $vURL = 'https://www.youtube.com/watch?v='.$vURL; $msg = strip_tags($msg); $msg = nsTrnc($msg, 500);
   while (stripos($frmData, '"hidden"')!==false){$frmData = substr($frmData, stripos($frmData, '"hidden"')+8); $name = trim(CutFromTo($frmData,'name="', '"'));
     if (!in_array($name, $md)) {$md[] = $name; $val = trim(CutFromTo($frmData,'value="', '"')); $flds[$name]= $val;}
   } $flds['message'] = $msg; $flds['video_url'] = $vURL; // prr($flds);
   $ytGPPageID = 'https://www.youtube.com/channel/'.$ytGPPageID; $hdrsArr = $this->headers($ytGPPageID, 'https://www.youtube.com/', 'POST', false); 
   $hdrsArr['X-YouTube-Page-CL'] = '67741289'; $hdrsArr['X-YouTube-Page-Timestamp'] = date("D M j H:i:s Y", time()-54000)." (".time().")"; //'Thu May 22 00:31:51 2014 (1400743911)';
   $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $flds, 'sslverify'=>$sslverify); //prr($advSet);
   $rep = nxs_remote_post('https://www.youtube.com/'.$actFormCode.'?action_add_bulletin=1', $advSet); 
   if (is_nxs_error($rep)) {  $badOut = print_r($rep, true)." - ERROR YT"; return $badOut; }  $contents = $rep['body'];// prr('https://www.youtube.com/'.$actFormCode.'?action_add_bulletin=1'); prr($rep);
           
   if ($rep['response']['code']=='200' && $contents = '{"code": "SUCCESS"}') return array("isPosted"=>"1", "postID"=>'', 'postURL'=>'', 'pDate'=>date('Y-m-d H:i:s')); else return $rep['response']['code']."|".$contents;     
 }              
예제 #8
0
파일: tw.api.php 프로젝트: JalpMi/v2contact
 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['twAccToken']) || trim($options['twAccToken']) == '') {
         $badOut['Error'] = 'No Auth Token Found';
         return $badOut;
     }
     //## Make Post
     $msg = $message['message'];
     $imgURL = trim($message['imageURL']);
     $img = trim($message['img']);
     $nxs_urlLen = $message['urlLength'];
     if ($options['attchImg'] == '1' && $img == '' && $imgURL == '') {
         $options['attchImg'] = 0;
     }
     if ($options['attchImg'] == '1' && $img == '' && $imgURL != '') {
         if (ini_get('allow_url_fopen')) {
             if (getimagesize($imgURL) !== false) {
                 $img = nxs_remote_get($imgURL);
                 if (is_nxs_error($img)) {
                     $options['attchImg'] = 0;
                 } else {
                     $img = $img['body'];
                 }
             } else {
                 $options['attchImg'] = 0;
             }
         } else {
             $img = nxs_remote_get($imgURL);
             if (is_nxs_error($img)) {
                 $options['attchImg'] = 0;
             } elseif (isset($img['body']) && trim($img['body']) != '') {
                 $img = $img['body'];
             } else {
                 $options['attchImg'] = 0;
             }
         }
     }
     if ($options['attchImg'] == '1' && $img != '') {
         $twLim = 118;
     } else {
         $twLim = 140;
     }
     require_once 'apis/tmhOAuth.php';
     require_once 'apis/tmhUtilities.php';
     if ($nxs_urlLen > 0) {
         $msg = nsTrnc($msg, $twLim - 22 + $nxs_urlLen);
     } else {
         $msg = nsTrnc($msg, $twLim);
     }
     $tmhOAuth = new NXS_tmhOAuth(array('consumer_key' => $options['twConsKey'], 'consumer_secret' => $options['twConsSec'], 'user_token' => $options['twAccToken'], 'user_secret' => $options['twAccTokenSec']));
     if ($options['attchImg'] == '1' && $img != '') {
         $code = $tmhOAuth->request('POST', 'http://upload.twitter.com/1/statuses/update_with_media.json', array('media[]' => $img, 'status' => $msg), true, true);
     } else {
         $code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' => $msg));
     }
     if ($code == '403' && stripos($tmhOAuth->response['response'], 'User is over daily photo limit') !== false && $options['attchImg'] == '1' && $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'] .= print_r($tmhOAuth->response['response'], true) . " MSG:" . print_r($msg, true);
         return $badOut;
     }
     return $badOut;
 }