当前位置: 首页>>代码示例>>PHP>>正文


PHP CutFromTo函数代码示例

本文整理汇总了PHP中CutFromTo函数的典型用法代码示例。如果您正苦于以下问题:PHP CutFromTo函数的具体用法?PHP CutFromTo怎么用?PHP CutFromTo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CutFromTo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nxs_doPublishToTW


//.........这里部分代码省略.........
                 }
                 if (stripos($pText, $cat->name) !== false) {
                     $pText = str_ireplace($cat->name, '#' . $frmTag, $pText);
                 } elseif (stripos($pText, $frmTag) !== false) {
                     $pText = str_ireplace($frmTag, '#' . $frmTag, $pText);
                 }
                 if (stripos($pFullText, $cat->name) !== false) {
                     $pFullText = str_ireplace($cat->name, '#' . $frmTag, $pFullText);
                 } elseif (stripos($pFullText, $frmTag) !== false) {
                     $pFullText = str_ireplace($frmTag, '#' . $frmTag, $pFullText);
                 }
                 if (stripos($pRawText, $cat->name) !== false) {
                     $pRawText = str_ireplace($cat->name, '#' . $frmTag, $pRawText);
                 } elseif (stripos($pRawText, $frmTag) !== false) {
                     $pRawText = str_ireplace($frmTag, '#' . $frmTag, $pRawText);
                 }
                 if (stripos($twMsgFormat, '%TITLE%') !== false && (stripos($pTitle, $cat->name) !== false || stripos($pTitle, $frmTag) !== false) || stripos($twMsgFormat, '%TEXT%') !== false && (stripos($pText, $cat->name) !== false || stripos($pText, $frmTag) !== false) || stripos($twMsgFormat, '%EXCERPT%') !== false && (stripos($pText, $cat->name) !== false || stripos($pText, $frmTag) !== false) || stripos($twMsgFormat, '%RAWEXCERPT%') !== false && (stripos($exrText, $cat->name) !== false || stripos($exrText, $frmTag) !== false) || stripos($twMsgFormat, '%ANNOUNCE%') !== false && (stripos($pText, $cat->name) !== false || stripos($pText, $frmTag) !== false) || stripos($twMsgFormat, '%FULLTEXT%') !== false && (stripos($pFullText, $cat->name) !== false || stripos($pFullText, $frmTag) !== false) || stripos($twMsgFormat, '%RAWTEXT%') !== false && (stripos($pRawText, $cat->name) !== false || stripos($pRawText, $frmTag) !== false)) {
                 } else {
                     $ctts[] = '#' . $frmTag;
                 }
             }
             $cats = implode(' ', $ctts);
             $tgsTwLim = $twLim - 20;
             $cats = nsTrnc($cats, $tgsTwLim, " ", "");
             $twMsgFormat = str_ireplace("%CATS%", $cats, $twMsgFormat);
             $twMsgFormat = str_ireplace("%HCATS%", $cats, $twMsgFormat);
             $twLim = $twLim - nxs_strLen($cats);
         }
         if (preg_match('/%H?CT-[a-zA-Z0-9_]+%/', $twMsgFormat)) {
             $msgA = explode('%CT', str_ireplace("%HCT", "%CT", $twMsgFormat));
             $mout = '';
             foreach ($msgA as $mms) {
                 if (substr($mms, 0, 1) == '-' && stripos($mms, '%') !== false) {
                     $mGr = CutFromTo($mms, '-', '%');
                     $cfItem = wp_get_post_terms($postID, $mGr, array("fields" => "names"));
                     if (is_nxs_error($cfItem)) {
                         nxs_addToLogN('E', 'Error', $logNT, '-=ERROR=- ' . $mGr . '|' . print_r($cfItem, true), $extInfo);
                     } else {
                         $tggs = array();
                         foreach ($cfItem as $frmTag) {
                             $frmTag = trim(str_replace(' ', $htS, preg_replace('/[^a-zA-Z0-9\\p{L}\\p{N}\\s]/u', '', trim(ucwords(str_ireplace('&', '', str_ireplace('&', '', $frmTag)))))));
                             $tggs[] = '#' . $frmTag;
                         }
                         $cfItem = implode(' ', $tggs);
                         $twLim = $twLim - nxs_strLen($cfItem);
                         $mms = str_ireplace("-" . $mGr . "%", $cfItem, $mms);
                     }
                 }
                 $mout .= $mms;
             }
             $twMsgFormat = $mout;
         }
         $twMsgFormat = str_ireplace("  ", " ", $twMsgFormat);
         if (stripos($twMsgFormat, '%TITLE%') !== false) {
             if (stripos($pTitle, '.co.uk') !== false) {
                 $twLim = $twLim - 14;
             }
             if (stripos($pTitle, '.com') !== false) {
                 $twLim = $twLim - 16;
             }
             if (stripos($pTitle, '.net') !== false) {
                 $twLim = $twLim - 16;
             }
             if (stripos($pTitle, '.org') !== false) {
                 $twLim = $twLim - 16;
             }
开发者ID:jguzmanf88,项目名称:social-networks-auto-poster-facebook-twitter-g,代码行数:67,代码来源:tw.php

示例2: doPostToBlogger

	function doPostToBlogger($blogID, $title, $msg, $tags = '') {
		$rnds = rndString ( 35 );
		$blogID = trim ( $blogID );
		$gpp = "http://www.blogger.com/blogger.g?blogID=" . $blogID;
		$refPage = "http://www.blogger.com/home";
		$contents = getCurlPageX ( $gpp, $refPage, true );
		$jjs = CutFromTo ( $contents, 'BloggerClientFlags=', '_layoutOnLoadHandler' );
		$j69 = ''; // prr($contents); echo "\r\n"; echo "\r\n";
		if ($j69 == '' && strpos ( $jjs, '64:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '64:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '65:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '65:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '66:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '66:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '67:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '67:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '68:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '68:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '69:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '69:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '70:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '70:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '71:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '71:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '72:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '72:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '73:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '73:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '74:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '74:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '75:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '75:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '76:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '76:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		if ($j69 == '' && strpos ( $jjs, '77:"' ) !== false) {
			$j69 = CutFromTo ( $jjs, '77:"', '"' );
			if (strpos ( $j69, ':' ) === false || (strpos ( $j69, '/' ) !== false))
				$j69 = '';
		}
		$gpp = "http://www.blogger.com/blogger_rpc?blogID=" . $blogID;
		$refPage = "http://www.blogger.com/blogger.g?blogID=" . $blogID;
		$spar = '{"method":"editPost","params":[,1,"","",,1,0,1,3,0,2,2,,0,[,,,,,,""],"en",0,[,' . date ( "Y" ) . ',' . date ( "n" ) . ',' . date ( "j" ) . ',' . date ( "G" ) . ',' . date ( "i" ) . '],,,0,"",[,1,[,0,0,0,0,0,0,0,0,0,"0"]],3],"xsrf":"' . $j69 . '"}';
		$contents = getCurlPageX ( $gpp, $refPage, true, $spar );
		$newpostID = CutFromTo ( $contents, '"result":[null,"', '"' );
		if ($tags != '')
			$pTags = '["' . $tags . '"]';
		else
			$pTags = ''; // prr($pTags);
		$pTags = str_replace ( '!', '', $pTags );
		$pTags = str_replace ( '.', '', $pTags );
		// $spar = '{"method":"editPost","params":[,1,"'.addslashes($title).'","'.addslashes($msg).'","'.$newpostID.'",0,0,1,3,0,2,2,'.$pTags.',0,[,,,,,,""],"en",0,[,'.date("Y").','.date("n").','.date("j").','.date("G").','.date("i").'],,,0,"",[,1,[,0,0,0,0,0,0,0,0,0,"0"]],1],"xsrf":"'.$j69.'"}';
		
		$msg = str_replace ( "'", '"', $msg );
		$msg = addslashes ( $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", '\n', $msg );
		
		$spar = '{"method":"editPost","params":{"1":1,"2":"' . addslashes ( $title ) . '","3":"' . $msg . '","4":"' . $newpostID . '","5":0,"6":0,"7":1,"8":3,"9":0,"10":2,"11":2,' . ($pTags != '' ? '"12":' . $pTags . ',' : '') . '"13":0,"14":{"6":""},"15":"en","16":0,"17":{"1":' . date ( "Y" ) . ',"2":' . date ( "n" ) . ',"3":' . date ( "j" ) . ',"4":' . date ( "G" ) . ',"5":' . date ( "i" ) . '},"20":0,"21":"","22":{"1":1,"2":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":"0"}},"23":1},"xsrf":"' . $j69 . '"}';
		
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:magento,代码行数:101,代码来源:postToGooglePlus.php

示例3: showGenNTSettings


//.........这里部分代码省略.........
                switch ($li_oauth->http_code) {
                    case 200:
                        $url = $li_oauth->generateAuthorizeUrl();
                        $optionsG = get_option('NS_SNAutoPoster');
                        $optionsG['li'][$_GET['acc']] = $options;
                        update_option('NS_SNAutoPoster', $optionsG);
                        echo '<script type="text/javascript">window.location = "' . $url . '"</script>';
                        break;
                    default:
                        echo '<br/><b style="color:red">Could not connect to LinkedIn. Refresh the page or try again later.</b>';
                        die;
                }
                die;
            }
            if (isset($_GET['auth']) && $_GET['auth'] == 'lia') {
                require_once 'apis/liOAuth.php';
                $options = $ntOpts[$_GET['acc']];
                $api_key = $options['liAPIKey'];
                $api_secret = $options['liAPISec'];
                $li_oauth = new nsx_LinkedIn($api_key, $api_secret);
                $li_oauth->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
                $li_oauth->oauth_verifier = $_REQUEST['oauth_verifier'];
                $li_oauth->getAccessToken($_REQUEST['oauth_verifier']);
                $options['liOAuthVerifier'] = $_REQUEST['oauth_verifier'];
                $options['liAccessToken'] = $li_oauth->access_token->key;
                $options['liAccessTokenSecret'] = $li_oauth->access_token->secret;
                try {
                    $xml_response = $li_oauth->getProfile("~:(id,first-name,last-name)");
                } catch (Exception $o) {
                    prr($o);
                    die("<span style='color:red;'>ERROR: Authorization Error</span>");
                }
                if (stripos($xml_response, '<first-name>') !== false) {
                    $userinfo = CutFromTo($xml_response, '<id>', '</id>') . " - " . CutFromTo($xml_response, '<first-name>', '</first-name>') . " " . CutFromTo($xml_response, '<last-name>', '</last-name>');
                } else {
                    $userinfo = '';
                }
                if ($userinfo != '') {
                    $options['liUserInfo'] = $userinfo;
                    $optionsG = get_option('NS_SNAutoPoster');
                    $optionsG['li'][$_GET['acc']] = $options;
                    update_option('NS_SNAutoPoster', $optionsG);
                    echo '<script type="text/javascript">window.location = "' . $nxs_snapSetPgURL . '"</script>';
                    die;
                }
                prr($xml_response);
                die("<span style='color:red;'>ERROR: Something is Wrong with your LinkedIn account</span>");
            }
            ?>
    
    <div class="nxs_box">
      <div class="nxs_box_header"> 
        <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php 
            echo $nxs_plurl;
            ?>
img/<?php 
            echo $ntInfo['lcode'];
            ?>
16.png);"><?php 
            echo $ntInfo['name'];
            ?>
          <?php 
            $cbo = count($ntOpts);
            ?>
 
          <?php 
开发者ID:Florian-Eschenbacher,项目名称:schneeeule,代码行数:67,代码来源:li.php

示例4: postYT

 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;     
 }              
开发者ID:xiaoguizhidao,项目名称:storebaby.it,代码行数:28,代码来源:postToGooglePlus.php

示例5: doPostToNT

 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;
     }
 }
开发者ID:voquanghoa,项目名称:WebPhim,代码行数:90,代码来源:bg.api.php

示例6: setNTSettings

 function setNTSettings($post, $options)
 {
     $code = 'VK';
     $lcode = 'vk';
     foreach ($post as $ii => $pval) {
         if (isset($pval['apVKAppID']) && $pval['apVKAppID'] != '') {
             if (!isset($options[$ii])) {
                 $options[$ii] = array();
             }
             if (isset($pval['apDoVK'])) {
                 $options[$ii]['doVK'] = $pval['apDoVK'];
             } else {
                 $options[$ii]['doVK'] = 0;
             }
             if (isset($pval['nName'])) {
                 $options[$ii]['nName'] = trim($pval['nName']);
             }
             if (isset($pval['apVKAppID'])) {
                 $options[$ii]['vkAppID'] = trim($pval['apVKAppID']);
             }
             if (isset($pval['uName'])) {
                 $options[$ii]['uName'] = trim($pval['uName']);
             }
             if (isset($pval['uPass'])) {
                 $options[$ii]['uPass'] = 'n5g9a' . nsx_doEncode($pval['uPass']);
             } else {
                 $options[$ii]['uPass'] = '';
             }
             if (isset($pval['vkPh'])) {
                 $options[$ii]['vkPh'] = trim($pval['vkPh']);
             }
             if (isset($pval['apVKAuthResp'])) {
                 $options[$ii]['apVKAuthResp'] = trim($pval['apVKAuthResp']);
                 $options[$ii]['vkAppAuthToken'] = trim(CutFromTo($pval['apVKAuthResp'] . '&', 'access_token=', '&'));
                 $options[$ii]['vkAppAuthUser'] = trim(CutFromTo($pval['apVKAuthResp'] . "&", 'user_id=', '&'));
                 $hdrsArr = nxs_getVKHeaders($pval['url']);
                 $response = wp_remote_get($pval['url'], array('method' => 'GET', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr));
                 if (is_wp_error($response)) {
                     echo "ERROR: <br/>";
                     prr($response);
                     return;
                 }
                 $contents = $response['body'];
                 $contents = utf8_decode($contents);
                 if (stripos($contents, '"group_id":') !== false) {
                     $options[$ii]['pgIntID'] = '-' . CutFromTo($contents, '"group_id":', ',');
                     $type = 'all';
                 }
                 if (stripos($contents, '"public_id":') !== false) {
                     $options[$ii]['pgIntID'] = '-' . CutFromTo($contents, '"public_id":', ',');
                     $type = 'all';
                 }
                 if (stripos($contents, '"user_id":') !== false) {
                     $options[$ii]['pgIntID'] = CutFromTo($contents, '"user_id":', ',');
                     $type = 'own';
                 }
             }
             if (isset($pval['catSel'])) {
                 $options[$ii]['catSel'] = trim($pval['catSel']);
             } else {
                 $options[$ii]['catSel'] = 0;
             }
             if ($options[$ii]['catSel'] == '1' && trim($pval['catSelEd']) != '') {
                 $options[$ii]['catSelEd'] = trim($pval['catSelEd']);
             } else {
                 $options[$ii]['catSelEd'] = '';
             }
             if (isset($pval['postType'])) {
                 $options[$ii]['postType'] = trim($pval['postType']);
             }
             if (isset($pval['attch'])) {
                 $options[$ii]['attch'] = $pval['attch'];
             } else {
                 $options[$ii]['attch'] = 0;
             }
             if (isset($pval['attchAsVid'])) {
                 $options[$ii]['attchAsVid'] = $pval['attchAsVid'];
             } else {
                 $options[$ii]['attchAsVid'] = 0;
             }
             if (isset($pval['apVKImgUpl'])) {
                 $options[$ii]['imgUpl'] = $pval['apVKImgUpl'];
             } else {
                 $options[$ii]['imgUpl'] = 0;
             }
             if (isset($pval['addBackLink'])) {
                 $options[$ii]['addBackLink'] = $pval['addBackLink'];
             } else {
                 $options[$ii]['addBackLink'] = 0;
             }
             if (isset($pval['msgFrmt'])) {
                 $options[$ii]['msgFrmt'] = trim($pval['msgFrmt']);
             }
             if (isset($pval['msgAFormat'])) {
                 $options[$ii]['msgAFormat'] = trim($pval['msgAFormat']);
             }
             $options[$ii] = nxs_adjRpst($options[$ii], $pval);
             if (isset($pval['delayDays'])) {
                 $options[$ii]['nDays'] = trim($pval['delayDays']);
             }
//.........这里部分代码省略.........
开发者ID:brettex,项目名称:pspark,代码行数:101,代码来源:vk.php

示例7: post

 function post($post)
 {
     $ck = $this->ck;
     $mh = $this->mh;
     $hdrsArr = $this->headers('http://www.deviantart.com/');
     $badOut = '';
     $advSets = array('headers' => $hdrsArr, 'cookies' => $ck);
     // prr($advSets);
     $rep = wp_remote_get($mh . '/journal/?edit', $advSets);
     if (is_wp_error($rep)) {
         $badOut = print_r($rep, true) . " - ERROR Post 1";
         return $badOut;
     }
     $contents = CutFromTo($rep['body'], '<h3 class="journal-editor-create">', '</form>');
     // prr($contents);
     $md = array();
     while (stripos($contents, '"hidden"') !== false) {
         $contents = substr($contents, stripos($contents, '"hidden"') + 8);
         $name = trim(CutFromTo($contents, 'name="', '"'));
         if (!in_array($name, $md)) {
             $md[] = $name;
             $val = trim(CutFromTo($contents, 'value="', '"'));
             $flds[$name] = urldecode(nxs_decodeEntities($val));
         }
     }
     $flds['subject'] = nsTrnc(nxs_decodeEntities($post['title']), 50);
     $flds['body'] = trim($post['text']);
     $flds['song'] = '';
     $flds['game'] = '';
     $flds['book'] = '';
     $flds['food'] = '';
     $flds['movie'] = '';
     $flds['drink'] = '';
     $flds['flip'] = '0';
     $flds['featured'] = '1';
     $flds['portal'] = '1';
     $flds['skinlabel'] = 'No+skin';
     $flds['jheader'] = '';
     $flds['jcss'] = '';
     $flds['jfooter'] = '';
     $ck2 = $rep['cookies'];
     for ($i = 0; $i < count($ck); $i++) {
         if ($ck[$i]->name == 'userinfo') {
             $ck[$i]->value = urlencode($ck2[0]->value);
         }
     }
     $fldsOut = $flds;
     $ckk = array();
     for ($i = 0; $i < count($ck); $i++) {
         if ($ck[$i]->name == 'userinfo' || $ck[$i]->name == 'auth') {
             $ckk[] = $ck[$i];
         }
     }
     $ck = $ckk;
     sleep(16);
     //## Important.
     $hdrsArr = $this->headers($mh . '/journal/?edit', $mh, true);
     $advSets = array('method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'body' => $fldsOut, 'cookies' => $ck);
     $response = wp_remote_post($mh . '/journal/?edit', $advSets);
     // prr($advSets); prr($response);
     if ($response['response']['code'] == '200' && stripos($response['body'], 'field_error') !== false) {
         $eRRMsg = CutFromTo($response['body'], 'field_error', '</div>');
         $eRRMsg = trim(strip_tags(CutFromTo($eRRMsg . "|GGG|", '>', '|GGG|')));
         $badOut = "POST Error: " . $eRRMsg;
         return $badOut;
     }
     if ($response['response']['code'] == '302') {
         $hdrsArr = $this->headers($mh);
         $rep = wp_remote_get($mh . '/journal/', array('headers' => $hdrsArr, 'cookies' => $ck));
         $daNewPostURL = CutFromTo($rep['body'], 'a data-deviationid="', '</a>');
         $daNewPostURL = CutFromTo($daNewPostURL, 'href="', '"');
         $daNewPostID = CutFromTo($rep['body'], 'a data-deviationid="', '"');
         return array('postID' => $daNewPostID, 'isPosted' => 1, 'postURL' => $daNewPostURL, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut .= 'Somethibng is not right';
         return $badOut;
     }
     return $badOut;
 }
开发者ID:voquanghoa,项目名称:WebPhim,代码行数:79,代码来源:da.api.php

示例8: post

 function post($post)
 {
     $ck = $this->ck;
     $mh = $this->mh;
     $hdrsArr = $this->headers('http://www.deviantart.com/');
     $badOut = '';
     $advSets = array('headers' => $hdrsArr, 'cookies' => $ck);
     // prr($advSets);
     $rep = wp_remote_get($mh . '/journal/?edit', $advSets);
     if (is_wp_error($rep)) {
         $badOut = print_r($rep, true) . " - ERROR Post 1";
         return $badOut;
     }
     $contents = CutFromTo($rep['body'], '<h3 class="journal-editor-create">', '</form>');
     // prr($contents);
     $md = array();
     while (stripos($contents, '"hidden"') !== false) {
         $contents = substr($contents, stripos($contents, '"hidden"') + 8);
         $name = trim(CutFromTo($contents, 'name="', '"'));
         if (!in_array($name, $md)) {
             $md[] = $name;
             $val = trim(CutFromTo($contents, 'value="', '"'));
             $flds[$name] = urldecode(nxs_decodeEntities($val));
         }
     }
     $flds['subject'] = nsTrnc(nxs_decodeEntities($post['title']), 50);
     $flds['body'] = trim($post['text']);
     $flds['song'] = '';
     $flds['game'] = '';
     $flds['book'] = '';
     $flds['food'] = '';
     $flds['movie'] = '';
     $flds['drink'] = '';
     $flds['flip'] = '0';
     $flds['featured'] = '1';
     $flds['portal'] = '1';
     $flds['skinlabel'] = 'No+skin';
     $flds['jheader'] = '';
     $flds['jcss'] = '';
     $flds['jfooter'] = '';
     $ck2 = $rep['cookies'];
     for ($i = 0; $i < count($ck); $i++) {
         if ($ck[$i]->name == 'userinfo') {
             $ck[$i]->value = urlencode($ck2[0]->value);
         }
     }
     $fldsOut = http_build_query($flds);
     $fldsOut = str_replace('No%2Bskin', 'No+skin', $fldsOut);
     $ckk = array();
     for ($i = 0; $i < count($ck); $i++) {
         if ($ck[$i]->name == 'userinfo' || $ck[$i]->name == 'auth') {
             $ckk[] = $ck[$i];
             if ($ck[$i]->name == 'userinfo') {
                 $ui = $ck[$i]->value;
             }
         }
     }
     $ck = $ckk;
     sleep(6);
     //## Important.
     $pid = CutFromTo($contents, '"pageviewID":"', '"');
     $iid = CutFromTo($contents, '"requestid":"', '"');
     $dflds = array('ui' => $ui, 'pid' => $pid, 'iid' => $iid . '-i7ex4avh-1.0', 't' => 'json');
     $dfldsq = http_build_query($dflds);
     $dfldsq1 = 'ui=' . $ui . '&c%5B%5D=%22Stash%22%2C%22create_journal%22%2C%5B%2235020854%22%2C%22' . urlencode($flds['subject']) . '%22%2C%22' . urlencode($flds['subject']) . '%22%2C%22-1%22%2C%7B%7D%5D&pid=' . $pid . '&iid=' . $iid . '-i7exlgzv-1.0&t=json';
     $hdrsArr = $this->headers($mh . '/journal/?edit', $mh, true);
     $advSets = array('method' => 'POST', 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'headers' => $hdrsArr, 'cookies' => $ck);
     $advSets['body'] = $dfldsq1;
     $rep = wp_remote_post($mh . '/global/difi/?', $advSets);
     //prr($mh.'/global/difi/?');  prr($advSets);       prr($rep);
     if (is_wp_error($rep)) {
         $badOut = print_r($rep, true) . " - ERROR DFI 1";
         return $badOut;
     }
     $cnt = $rep['body'];
     if (stripos($cnt, '"status":"SUCCESS"') === false || stripos($cnt, '"args":["') === false) {
         $badOut = print_r($cnt, true) . " - ERROR DFI 1.1";
         return $badOut;
     } else {
         $npid = CutFromTo($cnt, '"args":["', '"');
     }
     $dfldsq2 = 'ui=' . $ui . '&c%5B%5D=%22Deviation%22%2C%22DeleteSingle%22%2C%5B%' . $npid . '%22%2C%221%22%5D&pid=' . $pid . '&iid=' . $iid . '-i7exlgzv-1.0&t=json';
     $advSets['body'] = $dfldsq2;
     $rep = wp_remote_post($mh . '/global/difi/?', $advSets);
     // sleep(6); //## Important.      //prr($advSets); prr($rep); die();
     $advSets['body'] = $fldsOut;
     $response = wp_remote_post($mh . '/journal/?edit', $advSets);
     //prr($mh.'/journal/?edit');  prr($advSets); prr($response);
     if ($response['response']['code'] == '200' && stripos($response['body'], 'field_error') !== false) {
         $eRRMsg = CutFromTo($response['body'], 'field_error', '</div>');
         $eRRMsg = trim(strip_tags(CutFromTo($eRRMsg . "|GGG|", '>', '|GGG|')));
         $badOut = "POST Error: " . $eRRMsg;
         return $badOut;
     }
     if ($response['response']['code'] == '302') {
         $hdrsArr = $this->headers($mh);
         $rep = wp_remote_get($mh . '/journal/', array('headers' => $hdrsArr, 'cookies' => $ck));
         $daNewPostURL = CutFromTo($rep['body'], 'a data-deviationid="', '</a>');
         $daNewPostURL = CutFromTo($daNewPostURL, 'href="', '"');
         $daNewPostID = CutFromTo($rep['body'], 'a data-deviationid="', '"');
//.........这里部分代码省略.........
开发者ID:digideskio,项目名称:stammtisch,代码行数:101,代码来源:da.api.php

示例9: post

 function post($msg, $imgURL, $lnk, $boardID, $title = '', $price='', $via=''){ 
   $tk = $this->tk; $ck = $this->ck; $apVer = $this->apVer; if ($this->debug) echo "[PN] Posting to ...".$boardID."<br/>\r\n";      
   foreach ($ck as $c) if ( is_object($c) && $c->name=='csrftoken') $tk = $c->value; $msg = strip_tags($msg); $msg = substr($msg, 0, 480); $tgs = ''; $this->tk = $tk;
   if ($msg=='') $msg = '&nbsp;';  if (trim($boardID)=='') return "Board is not Set";  if (trim($imgURL)=='') return "Image is not Set";   $msg = str_ireplace(array("\r\n", "\n", "\r"), " ", $msg); 
   $msg = strip_tags($msg); if (function_exists('nxs_decodeEntitiesFull')) $msg = nxs_decodeEntitiesFull($msg, ENT_QUOTES); 
   $mgsOut = urlencode($msg); $mgsOut = str_ireplace(array('%28', '%29', '%27', '%21', '%22', '%09'), array("(", ")", "'", "!", "%5C%22", '%5Ct'), $mgsOut);     
   $fldsTxt = 'source_url=%2Fpin%2Ffind%2F%3Furl%3D'.urlencode(urlencode($lnk)).'&data=%7B%22options%22%3A%7B%22board_id%22%3A%22'.$boardID.'%22%2C%22description%22%3A%22'.$mgsOut.'%22%2C%22link%22%3A%22'.urlencode($lnk).'%22%2C%22share_twitter%22%3Afalse%2C%22image_url%22%3A%22'.urlencode($imgURL).'%22%2C%22method%22%3A%22scraped%22%7D%2C%22context%22%3A%7B%7D%7D';
   $hdrsArr = $this->headers('https://www.pinterest.com/resource/PinResource/create/ ', 'https://www.pinterest.com', 'POST', true);       
   $hdrsArr['X-NEW-APP']='1'; $hdrsArr['X-APP-VERSION']=$apVer; $hdrsArr['X-CSRFToken']=$tk; $hdrsArr['X-Pinterest-AppState']='active';  $hdrsArr['Accept'] = 'application/json, text/javascript, */*; q=0.01';      
   $advSet = array('headers' => $hdrsArr, 'httpversion' => '1.1', 'timeout' => 45, 'redirection' => 0, 'cookies' => $ck, 'body' => $fldsTxt); 
   $rep = nxs_remote_post('https://www.pinterest.com/resource/PinResource/create/', $advSet); if (is_nxs_error($rep)) {  $badOut = print_r($rep, true)." - ERROR"; return $badOut; }       
   $contents = $rep['body']; $resp = json_decode($contents, true); //  prr($advSet);  prr($resp);   prr($fldsTxt); // prr($contents);    
   if (is_array($resp)) {
     if (isset($resp['resource_response']) && isset($resp['resource_response']['error']) && $resp['resource_response']['error']!='' ) return print_r($resp['resource_response']['error'], true); 
     elseif (isset($resp['resource_response']) && isset($resp['resource_response']['data']) && $resp['resource_response']['data']['id']!=''){ // gor JSON
       if (isset($resp['resource_response']) && isset($resp['resource_response']['error']) && $resp['resource_response']['error']!='') return print_r($resp['resource_response']['error'], true);
       else return array("isPosted"=>"1", "postID"=>$resp['resource_response']['data']['id'], 'pDate'=>date('Y-m-d H:i:s'), "postURL"=>"http://www.pinterest.com/pin/".$resp['resource_response']['data']['id']);
     }    
   }elseif (stripos($contents, 'blocked this')!==false) { $retText = trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>'))));
     return "Pinterest ERROR: 'The Source is blocked'. Please see https://support.pinterest.com/entries/21436306-why-is-my-pin-or-site-blocked-for-spam-or-inappropriate-content/ for more info | Pinterest Message:".$retText;
   }  
   elseif (stripos($contents, 'image you tried to pin is too small')!==false) { $retText = trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>'))));
     return "Image you tried to pin is too small | Pinterest Message:".$retText;
   }  
   elseif (stripos($contents, 'CSRF verification failed')!==false) { $retText = trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>'))));
     return "CSRF verification failed - Please contact NextScripts Support | Pinterest Message:".$retText;
   }
   elseif (stripos($contents, 'Oops')!==false && stripos($contents, '<body>')!==false ) return 'Pinterest ERROR MESSAGE : '.trim(str_replace(array("\r\n", "\r", "\n"), " | ", strip_tags(CutFromTo($contents, '</head>', '</body>'))));
   else return "Somethig is Wrong - Pinterest Returned Error 502";         
 }    
开发者ID:xiaoguizhidao,项目名称:storebaby.it,代码行数:30,代码来源:postToPinterest.php

示例10: doPostToNT

 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;
     }
 }
开发者ID:digideskio,项目名称:stammtisch,代码行数:61,代码来源:kt.api.php

示例11: doPostToNT

 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');
//.........这里部分代码省略.........
开发者ID:digideskio,项目名称:stammtisch,代码行数:101,代码来源:bg.api.php

示例12: flUploadPhoto

 public function flUploadPhoto($imgFile, $parameters)
 {
     $url = 'https://www.flickr.com/services/upload/';
     $requestParams = $parameters == NULL ? array() : $parameters;
     $phid = '';
     $oauthParams = array('oauth_nonce' => $this->genRndString(), 'oauth_timestamp' => time(), 'oauth_token' => $this->access_token, 'oauth_consumer_key' => $this->consumer_key, 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_version' => '1.0');
     $requestParams = array_merge($requestParams, $oauthParams);
     $this->sign($url, $requestParams);
     $requestParams['photo'] = $imgFile;
     // prr($requestParams);
     $xml = $this->httpRequest($url, $requestParams);
     if (stripos($xml, '</photoid>') !== false && stripos($xml, 'stat="ok"') !== false) {
         $phid = CutFromTo($xml, '<photoid>', '</photoid>');
     }
     return empty($phid) ? "Problem: " . $xml . "<pre>" . print_r($requestParams, true) . "</pre>" : $phid;
 }
开发者ID:digideskio,项目名称:stammtisch,代码行数:16,代码来源:scOAuth.php

示例13: setNTSettings

 function setNTSettings($post, $options)
 {
     $code = 'LJ';
     $lcode = 'lj';
     foreach ($post as $ii => $pval) {
         if (isset($pval['apLJUName']) && $pval['apLJUName'] != '') {
             if (!isset($options[$ii])) {
                 $options[$ii] = array();
             }
             if (isset($pval['nName'])) {
                 $options[$ii]['nName'] = trim($pval['nName']);
             }
             if (isset($pval['ljSrv'])) {
                 $options[$ii]['ljSrv'] = trim($pval['ljSrv']);
             }
             if ($options[$ii]['ljSrv'] == 'DW') {
                 $server = 'dreamwidth.org';
             } else {
                 $server = 'livejournal.com';
             }
             if (isset($pval['apLJUName'])) {
                 $options[$ii]['ljUName'] = trim($pval['apLJUName']);
             }
             $options[$ii]['ljURL'] = 'http://' . $options[$ii]['ljUName'] . "." . $server;
             if (isset($pval['apLJPass'])) {
                 $options[$ii]['ljPass'] = 'n5g9a' . nsx_doEncode($pval['apLJPass']);
             } else {
                 $options[$ii]['ljPass'] = '';
             }
             if (isset($pval['apLJMsgFrmt'])) {
                 $options[$ii]['ljMsgFormat'] = trim($pval['apLJMsgFrmt']);
             }
             if (isset($pval['apLJMsgTFrmt'])) {
                 $options[$ii]['ljMsgTFormat'] = trim($pval['apLJMsgTFrmt']);
             }
             if (isset($pval['catSel'])) {
                 $options[$ii]['catSel'] = trim($pval['catSel']);
             } else {
                 $options[$ii]['catSel'] = 0;
             }
             if (isset($pval['inclTags'])) {
                 $options[$ii]['inclTags'] = $pval['inclTags'];
             } else {
                 $options[$ii]['inclTags'] = 0;
             }
             if ($options[$ii]['catSel'] == '1' && trim($pval['catSelEd']) != '') {
                 $options[$ii]['catSelEd'] = trim($pval['catSelEd']);
             } else {
                 $options[$ii]['catSelEd'] = '';
             }
             if (isset($pval['commID'])) {
                 if (stripos($pval['commID'], '.') !== false) {
                     $pval['commID'] = CutFromTo($pval['commID'], '://', '.');
                 }
                 $options[$ii]['commID'] = trim($pval['commID']);
             }
             if (isset($pval['apDoLJ'])) {
                 $options[$ii]['doLJ'] = $pval['apDoLJ'];
             } else {
                 $options[$ii]['doLJ'] = 0;
             }
             $options[$ii] = nxs_adjRpst($options[$ii], $pval);
             if (isset($pval['delayDays'])) {
                 $options[$ii]['nDays'] = trim($pval['delayDays']);
             }
             if (isset($pval['delayHrs'])) {
                 $options[$ii]['nHrs'] = trim($pval['delayHrs']);
             }
             if (isset($pval['delayMin'])) {
                 $options[$ii]['nMin'] = trim($pval['delayMin']);
             }
             if (isset($pval['qTLng'])) {
                 $options[$ii]['qTLng'] = trim($pval['qTLng']);
             }
         } elseif (count($pval) == 1) {
             if (isset($pval['apDo' . $code])) {
                 $options[$ii]['do' . $code] = $pval['apDo' . $code];
             } else {
                 $options[$ii]['do' . $code] = 0;
             }
         }
     }
     return $options;
 }
开发者ID:jguzmanf88,项目名称:social-networks-auto-poster-facebook-twitter-g,代码行数:84,代码来源:lj.php

示例14: post

 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);
 }
开发者ID:digideskio,项目名称:stammtisch,代码行数:58,代码来源:st.api.php

示例15: showGenNTSettings

        function showGenNTSettings($ntOpts)
        {
            global $nxs_snapThisPageUrl, $nxs_plurl;
            $ntInfo = array('code' => 'LI', 'lcode' => 'li', 'name' => 'LinkedIn', 'defNName' => 'ulName', 'tstReq' => true);
            if (isset($_GET['auth']) && $_GET['auth'] == 'li') {
                require_once 'apis/liOAuth.php';
                $options = $ntOpts[$_GET['acc']];
                $api_key = $options['liAPIKey'];
                $api_secret = $options['liAPISec'];
                $callback_url = $nxs_snapThisPageUrl . "&auth=lia&acc=" . $_GET['acc'];
                $li_oauth = new nsx_LinkedIn($api_key, $api_secret, $callback_url);
                $request_token = $li_oauth->getRequestToken();
                //echo "####"; prr($request_token); die();
                $options['liOAuthToken'] = $request_token->key;
                $options['liOAuthTokenSecret'] = $request_token->secret;
                // prr($li_oauth);
                switch ($li_oauth->http_code) {
                    case 200:
                        $url = $li_oauth->generateAuthorizeUrl();
                        $optionsG = get_option('NS_SNAutoPoster');
                        $optionsG['li'][$_GET['acc']] = $options;
                        update_option('NS_SNAutoPoster', $optionsG);
                        echo '<script type="text/javascript">window.location = "' . $url . '"</script>';
                        break;
                    default:
                        echo '<br/><b style="color:red">Could not connect to LinkedIn. Refresh the page or try again later.</b>';
                        die;
                }
                die;
            }
            if (isset($_GET['auth']) && $_GET['auth'] == 'lia') {
                require_once 'apis/liOAuth.php';
                $options = $ntOpts[$_GET['acc']];
                $api_key = $options['liAPIKey'];
                $api_secret = $options['liAPISec'];
                $li_oauth = new nsx_LinkedIn($api_key, $api_secret);
                $li_oauth->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);
                $li_oauth->oauth_verifier = $_REQUEST['oauth_verifier'];
                $li_oauth->getAccessToken($_REQUEST['oauth_verifier']);
                $options['liOAuthVerifier'] = $_REQUEST['oauth_verifier'];
                $options['liAccessToken'] = $li_oauth->access_token->key;
                $options['liAccessTokenSecret'] = $li_oauth->access_token->secret;
                try {
                    $xml_response = $li_oauth->getProfile("~:(id,first-name,last-name)");
                } catch (Exception $o) {
                    prr($o);
                    die("<span style='color:red;'>ERROR: Authorization Error</span>");
                }
                if (stripos($xml_response, '<first-name>') !== false) {
                    $userinfo = CutFromTo($xml_response, '<id>', '</id>') . " - " . CutFromTo($xml_response, '<first-name>', '</first-name>') . " " . CutFromTo($xml_response, '<last-name>', '</last-name>');
                } else {
                    $userinfo = '';
                }
                if ($userinfo != '') {
                    $options['liUserInfo'] = $userinfo;
                    $optionsG = get_option('NS_SNAutoPoster');
                    $optionsG['li'][$_GET['acc']] = $options;
                    update_option('NS_SNAutoPoster', $optionsG);
                    echo '<script type="text/javascript">window.location = "' . $nxs_snapThisPageUrl . '"</script>';
                    die;
                }
                prr($xml_response);
                die("<span style='color:red;'>ERROR: Something is Wrong with your LinkedIn account</span>");
            }
            ?>
    
    <div class="nxs_box">
      <div class="nxs_box_header"> 
        <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php 
            echo $nxs_plurl;
            ?>
img/<?php 
            echo $ntInfo['lcode'];
            ?>
16.png);"><?php 
            echo $ntInfo['name'];
            ?>
          <?php 
            $cbo = count($ntOpts);
            ?>
 <?php 
            wp_nonce_field('ns' . $ntInfo['code'], 'ns' . $ntInfo['code'] . '_wpnonce');
            ?>
          <?php 
            if ($cbo > 1) {
                ?>
<div class="nsBigText"><?php 
                echo "(" . ($cbo == '0' ? 'No' : $cbo) . " ";
                _e('accounts', 'nxs_snap');
                echo ")";
                ?>
</div><?php 
            }
            ?>
        </div>
      </div>
      <div class="nxs_box_inside">
        <?php 
            foreach ($ntOpts as $indx => $pbo) {
                if (trim($pbo['nName'] == '')) {
//.........这里部分代码省略.........
开发者ID:JalpMi,项目名称:v2contact,代码行数:101,代码来源:li.php


注:本文中的CutFromTo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。