伪原创API,如何对接PHP

在这个信息爆炸的时代,让自己的内容在网络海洋中脱颖而出,就像在繁星点点的夜空中成为最亮的那颗星星一样,既富有挑战又充满机遇。

伪原创API,如何对接PHP源码:

<?php

set_time_limit(270);
error_reporting(E_ERROR | E_WARNING | E_PARSE);

define('TITLE_SEPAR', 'xxx**xxx');
define('TITLE_SEPAR2', '262661');


$url = 'http://api.xiaofamao.com/api.php?json=0&v=1&key=etiaseo';

$content_tag_name = '内容';


$headdd = '';
$taill = '';



switch($LabelArray['PageType'])
{
    case 'List'://处理列表页,只能处理html
        break;
    case 'Pages'://处理多页,只能处理html
        break;
    case 'Content'://处理默认页,只能处理html
        break;
    case 'Save'://只有保存时是可以处理标签值的
        // 保存原文

    try {
    /**********************************************************************/
    // 这一步用来获取伪原创文章
    /**********************************************************************/

    $content = $LabelArray[$content_tag_name];

    $content_wyc = curl_request($url, array('wenzhang'=>$LabelArray[$content_tag_name] ));
    $content_wyc = fix_newline($content_wyc);
    $content_wyc = str_replace('标签:', '标签:', $content_wyc);
    $LabelArray[$content_tag_name] = $headdd. $content_wyc. $taill;
    $LabelArray['标题'] = get_ai_title1($LabelArray['标题']);
    }
    catch (Exception $e) {
        $LabelArray['标题'] .= $e->getMessage();
        $LabelArray[$content_tag_name] .= $e->getMessage();
    }
        break;
    default:
        //$LabelArray[$content_tag_name]=curl_request($url, array('wenzhang'=>$LabelArray[$content_tag_name] ));
}

echo serialize($LabelArray);

function get_ai_title1($title) {
    $title = urlencode($title);
    $url = 'http://api.xiaofamao.com/aititle/title.php?v=1&fuhao1=%2C&fuhao2=&key=aaa&title='.$title;
    $title_ai = curl_request($url);
    return $title_ai;
}

function compose_article($title, $content) {
    $separator = compose_separator();
    return $title.$separator.$content;
}

function compose_separator() {
    return PHP_EOL.'('.TITLE_SEPAR2.')'.PHP_EOL;
}


function fix_separator($article) {
    return $article;
}


function get_wyc_article($str) {
    global $url;
    $separator = compose_separator();
    $separator = str_replace(PHP_EOL, '', $separator);
    $wyc = curl_request($url, array('wenzhang'=>$str));

    $wyc_f = $wyc;
    $wyc = fix_separator($wyc);
    $wyc = explode($separator, $wyc);

    if (isset($wyc[0])){
        $wyc[0] = str_replace('标题:', '', $wyc[0]);
        $wyc[0] = str_replace('标题:', '', $wyc[0]);
        $wyc[0] = str_replace('目:', '', $wyc[0]);
        $wyc[0] = str_replace('目:', '', $wyc[0]);
        $wyc[0] = 'xx`xx'.$wyc[0];
        $wyc[0] = str_replace('xx`xx题', '', $wyc[0]);
        $wyc[0] = str_replace('xx`xx', '', $wyc[0]);
    }

    //if (isset($wyc[1])) $wyc[1] = trim($wyc[1]);
    //$wyc[1] = $wyc_f.'jjjjjjjj'.$wyc[1];
    return $wyc;
}


function get_wyc_title($str) {
    $title = get_wyc_article($str.PHP_EOL.PHP_EOL.PHP_EOL.$str.PHP_EOL.PHP_EOL.PHP_EOL.$str);
    $title = fix_newline($title);
    $title = explode(PHP_EOL, $title);
    return $title[0];
}

function get_keywords($title, $contents) {
    $url_kw = 'http://api-2.78tp.com/nlp/kws.php?appid=';
    $kws = curl_request($url_kw, array(
    'title'=>$title,
    'len'=>100,
    'text'=>$contents));

    return $kws;
}


function remove_alt($contents) {
    $contents = preg_replace('/alt=\"(.*)\"/', '', $contents);
    return $contents;
}


function fix_title($contents) {
    $punctuation_symbol = array('。', '?', ',', ':', ';', '、', '!',
                                '.',  '?',  ',',  ':',  ';', '!');

     $contents = str_replace($punctuation_symbol, '', $contents);
    return $contents;
}

function br2newline($contents) {
    $contents = str_replace('<br>', PHP_EOL, $contents);
    $contents = str_replace('<br/>', PHP_EOL, $contents);
    $contents = str_replace('<br />', PHP_EOL, $contents);
    $contents = str_replace('<BR/>', PHP_EOL, $contents);
    $contents = str_replace('<BR>', PHP_EOL, $contents);
    $contents = str_replace('<BR />', PHP_EOL, $contents);

    return $contents;
}

function newline2br($contnets) {
    $contnets = str_replace(PHP_EOL, "<br>", $contnets);
//    $contnets = str_replace('><br><', '><', $contnets);
    $contnets = str_replace('<p><br>', '<p>', $contnets);
    return $contnets;
}


function delete_newline($contents) {
    $contents = fix_newline($contents);
//    $contents = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $contents);
//    $contents = str_replace('>'.PHP_EOL, '>', $contents);
    return $contents;
}

function reset_newline_win($contents) {
    // 优化换行符
    $contents = str_replace("\r\n", "\n", $contents);
    $contents = str_replace("\r", "\n", $contents);
    $contents = str_replace("\n", PHP_EOL, $contents);

    return $contents;
}

function fix_newline($data) {
    $data = str_replace("\r", "\n", $data);
    while(strpos($data, "\n\n") !== false) {
        $data = str_replace("\n\n", "\n", $data);
    }
    $data = str_replace("\n", PHP_EOL, $data);

    return $data;
}

function clean_contents($contents) {
//    $str = preg_replace('#<([^>\s/]+)[^>]*>#','<$1>', $contents);
//    return $str;
    $sa = new cleanHtml;  
    $sa->allow = array( 'src' );    
    $sa->exceptions = array(  
    'img' => array( 'src', 'alt' ),  
    //'a' => array( 'href', 'title' ),  
    'iframe'=>array('src','frameborder'),  
    ); 
    $str = $sa->strip( $contents );   

    return $str;
}


function xfm_strong_str_replace_once($search, $replace, $subject) {
    $firstChar = strpos($subject, $search);
    if($firstChar !== false) {
        $beforeStr = substr($subject,0,$firstChar);
        $afterStr = substr($subject, $firstChar + strlen($search));
        return $beforeStr.$replace.$afterStr;
    } else {
        return $subject;
    }
}

//参数1:访问的URL,参数2:post数据(不填则为GET),参数3:提交的$cookies,参数4:是否返回$cookies
function curl_request($url,$post='',$cookie='', $returnCookie=0){
    if (! extension_loaded('curl')) {
        file_exists('./ext/php_curl.dll') && dl('php_curl.dll'); // 加载扩展
    }
    
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)');
    if (ini_get('open_basedir') == '' && strtolower(ini_get('safe_mode')) != 'on'){ 
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    }
        curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
        curl_setopt($curl, CURLOPT_REFERER, "http://XXX");
        if($post) {
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
        }
        if($cookie) {
            curl_setopt($curl, CURLOPT_COOKIE, $cookie);
        }
        curl_setopt($curl, CURLOPT_HEADER, $returnCookie);
        curl_setopt($curl, CURLOPT_TIMEOUT, 150);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $data = curl_exec($curl);
        if (curl_errno($curl)) {
            return curl_error($curl);
        }
        curl_close($curl);
        if($returnCookie){
            list($header, $body) = explode("\r\n\r\n", $data, 2);
            preg_match_all("/Set\-Cookie:([^;]*);/", $header, $matches);
            $info['cookie']  = substr($matches[1][0], 1);
            $info['content'] = $body;
            return $info;
        }else{
            return $data;
        }
}

//echo $tag;
// 计算中文字符串长度
function utf8_strlen($string = null) {
// 将字符串分解为单元
preg_match_all("/./us", $string, $match);
// 返回单元个数
return count($match[0]);
}


function reg_escape( $str )  
{  
    $conversions = array( "^" => "\^", "[" => "\[", "." => "\.", "$" => "\$", "{" => "\{", "*" => "\*", "(" => "\(", "\\" => "\\\\", "/" => "\/", "+" => "\+", ")" => "\)", "|" => "\|", "?" => "\?", "<" => "\<", ">" => "\>" );  
    return strtr( $str, $conversions );  
}  
  
/** 
* Strip attribute Class 
* Remove attributes from XML elements 
* @author David (semlabs.co.uk) 
* @version 0.2.1 
*/  
  
class cleanHtml{  
      
    public $str         = '';  
    public $allow       = array();  
    public $exceptions  = array();  
    public $ignore      = array();  
      
    public function strip( $str )  
    {  
        $this->str = $str;  
          
        if( is_string( $str ) && strlen( $str ) > 0 )  
        {  
            $res = $this->findElements();  
            if( is_string( $res ) )  
                return $res;  
            $nodes = $this->findAttributes( $res );  
            $this->removeAttributes( $nodes );  
        }  
          
        return $this->str;  
    }  
      
    private function findElements()  
    {  
        # Create an array of elements with attributes  
        $nodes = array();  
        preg_match_all( "/<([^ !\/\>\n]+)([^>]*)>/i", $this->str, $elements );  
        foreach( $elements[1] as $el_key => $element )  
        {  
            if( $elements[2][$el_key] )  
            {  
                $literal = $elements[0][$el_key];  
                $element_name = $elements[1][$el_key];  
                $attributes = $elements[2][$el_key];  
                if( is_array( $this->ignore ) && !in_array( $element_name, $this->ignore ) )  
                    $nodes[] = array( 'literal' => $literal, 'name' => $element_name, 'attributes' => $attributes );  
            }  
        }  
          
        # Return the XML if there were no attributes to remove  
        if( !$nodes[0] )  
            return $this->str;  
        else  
            return $nodes;  
    }  
      
    private function findAttributes( $nodes )  
    {  
          
        # Extract attributes  
        foreach( $nodes as &$node )  
        {  
            preg_match_all( "/([^ =]+)\s*=\s*[\"|']{0,1}([^\"']*)[\"|']{0,1}/i", $node['attributes'], $attributes );  
            if( $attributes[1] )  
            {  
                foreach( $attributes[1] as $att_key => $att )  
                {  
                    $literal = $attributes[0][$att_key];  
                    $attribute_name = $attributes[1][$att_key];  
                    $value = $attributes[2][$att_key];  
                    $atts[] = array( 'literal' => $literal, 'name' => $attribute_name, 'value' => $value );  
                }  
            }  
            else  
                $node['attributes'] = null;  
              
            $node['attributes'] = $atts;  
            unset( $atts );  
        }  
          
        return $nodes;  
    }  
      
    private function removeAttributes( $nodes )  
    {  
          
        # Remove unwanted attributes  
        foreach( $nodes as $node )  
        {  
              
            # Check if node has any attributes to be kept  
            $node_name = $node['name'];  
            $new_attributes = '';  
            if( is_array( $node['attributes'] ) )  
            {  
                foreach( $node['attributes'] as $attribute )  
                {  
                    if( ( is_array( $this->allow ) && in_array( $attribute['name'], $this->allow ) ) || $this->isException( $node_name, $attribute['name'], $this->exceptions ) )  
                        $new_attributes = $this->createAttributes( $new_attributes, $attribute['name'], $attribute['value'] );  
                }  
            }  
            $replacement = ( $new_attributes ) ? "<$node_name $new_attributes>" : "<$node_name>";  
            $this->str = preg_replace( '/'. reg_escape( $node['literal'] ) .'/', $replacement, $this->str );  
        }  
          
    }  
      
    private function isException( $element_name, $attribute_name, $exceptions )  
    {  
        if( array_key_exists($element_name, $this->exceptions) )  
        {  
            if( in_array( $attribute_name, $this->exceptions[$element_name] ) )  
                return true;  
        }  
          
        return false;  
    }  
      
    private function createAttributes( $new_attributes, $name, $value )  
    {  
        if( $new_attributes )  
            $new_attributes .= " ";  
        $new_attributes .= "$name=\"$value\"";  
          
        return $new_attributes;  
    }  
  
}  

?>

而谈及如何让文章、视频或博客等创作被搜索引擎青睐,就如同在广袤无垠的森林里,为你的小屋点亮一盏引人注目的灯塔。这时,“伪原创API”就像是那把秘钥,能巧妙地为你的内容披上新装,吸引更多探索者的目光。

想象一下,你是一位大厨,每天烹饪着各式佳肴,但随着时间流逝,客人们开始渴望新的口味。这时,你不必完全抛弃那些经典菜谱,而是通过调整配料比例、创新摆盘方式,甚至融入异国风味,让老菜焕发新生。这便是“伪原创API”的精髓所在——它不创造全新的文本,而是通过对现有内容的智能改写、同义词替换和句式调整,让你的文章既保留核心信息,又呈现出新颖的面貌,从而提升搜索引擎的收录率,吸引更多的自然流量。

使用伪原创API的过程,就像是给你的文章进行一次“文字SPA”。它不是简单粗暴的复制粘贴,而是如同一位技艺高超的文字造型师,细致入微地调整每一个词汇、每一句话,确保改造后的文章既保持了原意,又充满了新鲜感。这样的文章更容易被搜索引擎视为独特内容,从而在搜索结果中获得更高的排名,相当于在互联网的舞台上,为你的作品争取到了前排座位。

当然,正如一位优秀的厨师不会忘记食材的本质,我们在利用伪原创API时,也需谨记内容的质量是根本。

伪原创api接口开放平台

华丽的辞藻和新颖的表达虽能吸引眼球,但真正留住人心的,还是内容的深度与价值。因此,在追求收录与流量的同时,也不应忽视对内容质量的打磨,让每一篇文章都能成为既有颜值又有内涵的精品。

总而言之,伪原创API就像是为你的网络内容穿上了一件量身定制的新衣,不仅提升了外在吸引力,也让内在价值得以更好地展现。只要恰到好处地运用这一工具,就能在茫茫网海中,让你的作品如同璀璨的星辰,被更多人发现并赞赏。

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
东南亚位于我国倡导推进的“一带一路”海陆交汇地带,作为当今全球发展最为迅速的地区之一,近年来区域内生产总值实现了显著且稳定的增长。根据东盟主要经济体公布的最新数据,印度尼西亚2023年国内生产总值(GDP)增长5.05%;越南2023年经济增长5.05%;马来西亚2023年经济增速为3.7%;泰国2023年经济增长1.9%;新加坡2023年经济增长1.1%;柬埔寨2023年经济增速预计为5.6%。 东盟国家在“一带一路”沿线国家中的总体GDP经济规模、贸易总额与国外直接投资均为最大,因此有着举足轻重的地位和作用。当前,东盟与中国已互相成为双方最大的交易伙伴。中国-东盟贸易总额已从2013年的443亿元增长至 2023年合计超逾6.4万亿元,占中国外贸总值的15.4%。在过去20余年中,东盟国家不断在全球多变的格局里面临挑战并寻求机遇。2023东盟国家主要经济体受到国内消费、国外投资、货币政策、旅游业复苏、和大宗商品出口价企稳等方面的提振,经济显现出稳步增长态势和强韧性的潜能。 本调研报告旨在深度挖掘东南亚市场的增长潜力与发展机会,分析东南亚市场竞争态势、销售模式、客户偏好、整体市场营商环境,为国内企业出海开展业务提供客观参考意见。 本文核心内容: 市场空间:全球行业市场空间、东南亚市场发展空间。 竞争态势:全球份额,东南亚市场企业份额。 销售模式:东南亚市场销售模式、本地代理商 客户情况:东南亚本地客户及偏好分析 营商环境:东南亚营商环境分析 本文纳入的企业包括国外及印尼本土企业,以及相关上下游企业等,部分名单 QYResearch是全球知名的大型咨询公司,行业涵盖各高科技行业产业链细分市场,横跨如半导体产业链(半导体设备及零部件、半导体材料、集成电路、制造、封测、分立器件、传感器、光电器件)、光伏产业链(设备、硅料/硅片、电池片、组件、辅料支架、逆变器、电站终端)、新能源汽车产业链(动力电池及材料、电驱电控、汽车半导体/电子、整车、充电桩)、通信产业链(通信系统设备、终端设备、电子元器件、射频前端、光模块、4G/5G/6G、宽带、IoT、数字经济、AI)、先进材料产业链(金属材料、高分子材料、陶瓷材料、纳米材料等)、机械制造产业链(数控机床、工程机械、电气机械、3C自动化、工业机器人、激光、工控、无人机)、食品药品、医疗器械、农业等。邮箱:market@qyresearch.com

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值