ai伪原创api 先上代码吧。
<?php
header("Content-type: text/html; charset=gb2312");
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', '1');
define ("CUR_DIR", '../');
define('TITLE_SEPAR', 'xxxxx');
// 这里是你的API地址
define('API_URL', 'http://api.xiaofamao.com/api.php?json=0&v=2&key=yuyu');
// 待执行目录
define('CUR_FOLDER', CUR_DIR.'word');
// 执行后保存目录
define('DEST_FOLDER', CUR_DIR.'xiaofamao');
// 执行后保存目录 失败
define('DEST_FOLDER_FAIL', CUR_DIR.'xiaofamao_fail');
$one_file = get_one_file();
// 判断是否还有任务
if (!$one_file){
echo PHP_EOL.'* 任务数为0, 程序已退出';
exit;
}
while ($one_file) {
echo PHP_EOL.'* 正在执行:' . PHP_EOL. file_path($one_file);
echo PHP_EOL.'* 请耐心等候...';
$data_arr = get_contents_filter(file_path($one_file));
$title = $data_arr['title'];
$title_src = $data_arr['title'];
$content = $data_arr['content'];
$content = replace_shuminghao($content);
$content = get_utf8_data($content);
$new_content = curl_request(API_URL, array('wenzhang'=>$content));
$new_content = get_gbk_data($new_content);
$new_content = restore_shuminghao($new_content);
#var_dump($new_content);
$new_content = content_format($new_content);
$new_content = $new_content;
#$new_title = get_ai_title($title);
$title = get_utf8_data($title);
$new_title = $title;
//$new_title =curl_request(API_URL, array('wenzhang'=>$title));
//$new_title = get_gbk_data($new_title);
#echo $new_title;
# 如果标题伪原创成功
if ($new_title === 'xx'.$title) {
$new_title = get_gbk_data($title);
//save_new_file(DEST_FOLDER_FAIL.DIRECTORY_SEPARATOR.$new_title.'.txt', $new_content);
save_new_file(DEST_FOLDER_FAIL.DIRECTORY_SEPARATOR.$title_src.'.txt', $new_content);
}
else {
$new_title = strip_tags($new_title);
$new_title = str_replace(':', ":", $new_title);
$new_title = str_replace('?', "?", $new_title);
$new_title = str_replace(array('*','"','<','>','|'),'_', $new_title);
$new_title = get_gbk_data($new_title);
#$title = get_gbk_data($title);
#save_new_file(DEST_FOLDER.DIRECTORY_SEPARATOR.$new_title.'.txt', $new_content);
save_new_file(DEST_FOLDER.DIRECTORY_SEPARATOR.$title_src.'.txt', $new_content);
#save_new_file(DEST_FOLDER.DIRECTORY_SEPARATOR.$new_title.'.txt', $content);
}
//
//
#save_new_file(DEST_FOLDER.DIRECTORY_SEPARATOR.$title.'.txt', $new_content);
file_ok($one_file);
//show_info_gb2312('伪原创结果:'.PHP_EOL. $final_data);
//save_new_file(DEST_FOLDER.DIRECTORY_SEPARATOR.$new_title, $new_content);
//var_dump($final_data);
// sleep(3);
$one_file = get_one_file();
// show_reflesh();
}
show_info_gb2312(PHP_EOL.'任务完成'.PHP_EOL);
function replace_shuminghao($content) {
$content = str_replace('![](', '<(', $content);
$count = preg_match_all("/<\((.*?)\)/", $content, $matches);
#var_dump($matches[0]);
if (isset($matches[0][0]))
{
foreach ($matches[0] as $key => $value) {
#echo $value;
$new_val = '《'.$matches[1][$key].'》';
$content = str_replace($value, $new_val, $content);
}
}
#echo $content;
return $content;
}
function restore_shuminghao($content) {
$count = preg_match_all("/《http(.*?)》/", $content, $matches);
#var_dump($matches[0]);
if (isset($matches[0][0]))
{
foreach ($matches[0] as $key => $value) {
$new_val = '![](http'.$matches[1][$key].')';
$content = str_replace($value, $new_val, $content);
}
#return $matches[0];
}
return $content;
}
function content_rewrite($content) {
$data = curl_request(API_URL, array('wenzhang'=>$content));
return $data;
}
function content_format($data) {
$data = fix_newline($data);
$data_arr = explode(PHP_EOL, $data);
$ret_str = '';
foreach($data_arr as $key => $value) {
#echo $value;
$ret_str .= ' '.$value.PHP_EOL.PHP_EOL;
#$ret_str .= 'bbbbbbbbbbbbbbbbbb';
}
return $ret_str;
}
function title_content_rewrite($title, $content) {
$article_src = $title.TITLE_SEPAR.PHP_EOL.$content;
$data = curl_request(API_URL, array('wenzhang'=>$article_src));
$data = str_replace("Xx", "xx", $data);
$data = str_replace("\n", "\r\n", $data);
$data = str_replace("<p>\r\n", "<p>", $data);
$data = ltrim($data);
#var_dump($data);
$temp = explode(TITLE_SEPAR, $data);
#var_dump($temp);
$temp[0] = trim($temp[0]);
$temp[1] = ltrim($temp[1]);
$temp[1] = ltrim($temp[1], '</p>');
$temp[1] = ltrim($temp[1]);
$temp[1] = ltrim($temp[1]);
return $temp;
}
function show_info($str) {
echo '<p>' . $str . '</p>';
}
function get_utf8_data($data) {
$encode = mb_detect_encoding($data, array('ASCII', 'UTF-8', 'GB2312', 'GBK','BIG5'));
if ($encode !== 'UTF-8') {
//show_info_gb2312('文件非 UTF-8,正在转成UTF-8');
$utf8_data = iconv($encode, 'UTF-8//IGNORE', $data);
return $utf8_data;
}
return $data;
}
function get_gbk_data($data) {
$encode = mb_detect_encoding($data, array('ASCII', 'UTF-8', 'GB2312', 'GBK','BIG5'));
if ($encode === 'UTF-8') {
//show_info_gb2312('文件非 UTF-8,正在转成UTF-8');
$gbk_data = iconv('UTF-8//IGNORE', 'GBK//IGNORE', $data);
return $gbk_data;
}
return $data;
}
function get_ai_title($title) {
$title = urlencode($title);
return curl_request($url);
}
function show_info_gb2312($string) {
echo get_gbk_data($string);
newline();
}
function get_img_arr($array) {
$ret_arr = array();
foreach ($array[1] as $key => $value) {
if (stripos($value, 'C:\\') === 0) {
$ret_arr[0][] = $value;
}
else {
$ret_arr[1][] = $value;
}
}
asort($ret_arr);
return $ret_arr;
}
function 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;
}
}
//var_dump(str_replace_once('**x**', 'xxxxxxxxxx', 'aaa**x**bbb'));
//exit;
function put_img_arr($array, $string) {
$string = str_replace('**X**', '**x**', $string);
foreach ($array as $key => $value) {
$string = str_replace_once('**x**', $value, $string);
}
return $string;
}
function get_rewrite_title($data) {
// var_dump($data);
$data = reset_newline($data);
$data_arr = explode(PHP_EOL, $data);
$title = str_replace(array('<P>', '<p>'), array('',''), $data_arr[0]);
array_shift($data_arr);
$contents = '<p>'.implode(PHP_EOL, $data_arr);
$new_arr = array($title, $contents);
return $new_arr;
}
/*
foreach ($news_list as $key => $value) {
echo $value."<br>".PHP_EOL;
$value = iconv("utf-8", "gb2312", $value);
$data = file_get_contents($value);
$data = iconv("GBK", "utf-8", $data);
// echo $data;
$data = rewrite($data);
$data = str_replace("\r\n", "\n", $data);
$data = str_replace("\r", "\n", $data);
$data = str_replace("\n", "\r\n", $data);
sleep(2);
$data = auto_typeset($data);
save_new_file('b'.$value, $data);
}
*/
function auto_typeset($data) {
$data = str_replace(
array('<P>'."\r\n", '<P>', '<p>'),
array('<p>', '<p>', '<p> '),
$data
);
return $data;
}
function rewrite($article) {
$url = API_URL;
return curl_request($url, array('wenzhang'=>$article ));
}
function save_new_file($filename, $data) {
if (! data_exists($filename)) {
file_put_contents($filename, $data);
}
}
// 缓存数据是否存在
function data_exists($filename) {
$filename = str_replace('\\','/', $filename);
// var_dump($filename);
// var_dump(dirname($filename));
if (!is_dir(dirname($filename))) {
// echo 'aaaaaaaaaaa';
mkdir(dirname($filename),0755,true);
}
// var_dump(dirname(dirname($filename)));
if (!is_dir(dirname(dirname($filename)))) {
// echo 'bbbbbbbbbb';
mkdir(dirname(dirname($filename)),0755,true);
}
if (file_exists($filename)) {
return true;
}
return false;
}
function get_news_list($floder) {
$news_list = array();
if($handle = opendir($floder)){
while (false !== ($file = readdir($handle))){
//$dir = iconv("utf-8", "gb2312", $file);
$file = iconv("gb2312", "utf-8", $file);
if ($file !== '..' && $file !== '.')
{
$news_list[] = $floder.DIRECTORY_SEPARATOR.$file;
}
// echo "$file\n";
}
closedir($handle);
}
return $news_list;
}
//参数1:访问的URL,参数2:post数据(不填则为GET),参数3:提交的$cookies,参数4:是否返回$cookies
function curl_request($url,$post='',$cookie='', $returnCookie=0){
$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;
}
}
// 计算中文字符串长度
function utf8_strlen($string = null) {
// 将字符串分解为单元
preg_match_all("/./us", $string, $match);
// 返回单元个数
return count($match[0]);
}
function get_one_file() {
$arr_all = get_all_files();
#var_dump( $arr_all );
$arr_ok = get_ok_files();
//var_dump($arr_ok);
foreach($arr_all as $v) {
if (array_search($v, $arr_ok)===false) {
return $v;
}
}
return false;
}
function get_all_files() {
return listDir(CUR_FOLDER);
}
function get_ok_files() {
//var_dump(CUR_DIR.'ok.txt');
$data = file_get_contents(CUR_DIR.'ok.txt');
$data = str_replace("\xef\xbb\xbf", '', $data);
$data_arr = explode(PHP_EOL, $data);
return $data_arr;
}
function file_ok($file_name) {
file_put_contents(CUR_DIR.'ok.txt', $file_name.PHP_EOL, FILE_APPEND);
}
function listDir($dir)
{
// echo $dir;
$reta = array();
if(is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if((is_dir($dir."/".$file)) && $file!="." && $file!="..")
{
//echo 'aa';
//$file = iconv("gb2312", "utf-8//IGNORE", $file);
// $file = ConvertToUTF8($file);
#$file = mb_convert_encoding($file, 'UTF-8', 'GBK');
$reta[] = $file;
// echo "<b><font color='red'>文件名:</font></b>",$file,"<br><hr>";
listDir($dir."/".$file."/");
}
else
{
if($file!="." && $file!="..")
{
// echo $file."<br>";
if (stripos($file, '.txt')!==false) {
#$file = iconv("GBK", "utf-8//IGNORE", $file);
// echo $file.'<br>';
$reta[] = $file;
}
}
}
}
closedir($dh);
}
}
//var_dump($reta);
return $reta;
}
function file_path($filename) {
return CUR_FOLDER.DIRECTORY_SEPARATOR.$filename;
}
function short_filename($filename) {
$filename = str_replace(CUR_FOLDER.DIRECTORY_SEPARATOR, '', $filename);
$filename = str_replace('.txt', '', $filename);
return $filename;
}
function get_contents_filter($file_name) {
$file_name = get_gbk_data($file_name);
// $file_name = mb_convert_encoding($file_name, 'UTF-8', 'ISO-8859-15');
/// $file_name = iconv("utf-8", "GBK//IGNORE", $file_name);
// echo $file_name.'<br>';
$data = file_get_contents($file_name);
$data = get_gbk_data($data);
$data = str_replace("\t", '', $data);
// 优化换行符
$data = fix_newline($data);
$data_title = short_filename($file_name);
//var_dump(get_utf8_data($data));
return array('title'=>$data_title, 'content'=>$data);
}
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 show_reflesh() {
$str = '<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout("myrefresh()",1000);
</script>';
echo $str;
}
function after ($this, $inthat)
{
if (!is_bool(strpos($inthat, $this)))
return substr($inthat, strpos($inthat,$this)+strlen($this));
};
function after_last ($this, $inthat)
{
if (!is_bool(strrevpos($inthat, $this)))
return substr($inthat, strrevpos($inthat, $this)+strlen($this));
};
function before ($this, $inthat)
{
return substr($inthat, 0, strpos($inthat, $this));
};
function before_last ($this, $inthat)
{
return substr($inthat, 0, strrevpos($inthat, $this));
};
function between ($this, $that, $inthat)
{
return before ($that, after($this, $inthat));
};
function between_last ($this, $that, $inthat)
{
return after_last($this, before_last($that, $inthat));
};
// use strrevpos function in case your php version does not include it
function strrevpos($instr, $needle)
{
$rev_pos = strpos (strrev($instr), strrev($needle));
if ($rev_pos===false) return false;
else return strlen($instr) - $rev_pos - strlen($needle);
};
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
if (strpos($file, '.txt') === false) {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
}
closedir($dir);
}
function ConvertToUTF8($text){
$encoding = mb_detect_encoding($text, mb_detect_order(), false);
if($encoding == "UTF-8")
{
$text = mb_convert_encoding($text, 'UTF-8', 'UTF-8');
}
$out = iconv(mb_detect_encoding($text, mb_detect_order(), false), "UTF-8//IGNORE", $text);
return $out;
}
function newline() {
echo PHP_EOL;
}
function sanitizeUTF8($value)
{
if (self::getIsIconvEnabled()) {
// NEW ----------------------------------------------------------------
$encoding = mb_detect_encoding($value, mb_detect_order(), false);
if($encoding == "UTF-8")
{
$value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
}
$value = iconv(mb_detect_encoding($value, mb_detect_order(), false), "UTF-8//IGNORE", $value);
// --------------------------------------------------------------------
// OLD --------------------------------------
// $value = @iconv('UTF-8', 'UTF-8', $value);
// -------------------------------------------
return $value;
}
$value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
return $value;
}
?>
火车头伪原创插件是一种用于更新网站的工具,对于非专业人士可能不太熟悉。今天我们来介绍一下网页设计和排版对于搜索引擎优化(SEO)的影响。不可否认,人工智能(AI)智能伪原创系统的出现最大程度上提高了伪原创工作的效率。
基于AI伪原创PHP的文章在网站SEO优化中被收录后是可以进行修改的。因为修改后,该页面会重新被搜索引擎索引,并重新审核。如果页面符合标准,就会再次被收录。但在修改已被收录的文章时,我们仍需注意方法。ai伪原创api,如何用php调用
很多人因为各种原因使用伪原创写作工具来生成文章。这确实可以帮助他们解决许多问题,适应大众需求。例如,他们可能不愿意亲自写全方位的文章,或者他们觉得写文章很困难,无法写出任何内容。
火车头伪原创-基于AI伪原创PHP
使用火车头伪原创的注意事项:
1、对于那些没有使用过伪原创写作工具的人来说,火车头是一个多彩的世界,他们常常有疑虑:“伪原创写作工具生成的文章好吗?这些文章能否通顺可读?”事实上,随着AI技术的发展,许多由伪原创写作工具生成的文章已经无法辨别其是由工具创作还是由人手写的。
2、这篇文章的文字内容并非由边肖亲自写下,而是由小猫AI伪原创写作工具生成的。如果边肖不说出真相,大家能看出这是伪原创写作工具生成的吗?相信大家无法辨别,因为阅读这篇文章时感到非常流畅,句子之间也没有矛盾。因此,这个案例足以证明伪原创写作工具生成的文章质量非常好。
3、在这些优秀的文章中,并非所有由伪原创写作工具生成的文章都是高质量的。因此我们需要仔细挑选由AI技术开发的伪原创写作工具。比如边肖目前使用的这只小猫AI伪原创写作工具具备十年的经验。因为这类伪原创写作工具基于自然语言技术,能够以人类写作的方式创造新的文章,所以大多数由这类工具生成的文章质量都很高。文章来源:https://www.toymoban.com/news/detail-518190.html
综上所述,火车头伪原创写作工具生成的文章质量如何?相互证实,边肖在此分享。如果有问题,可以在下方留言讨论无数次。感谢您的阅读!文章来源地址https://www.toymoban.com/news/detail-518190.html
到了这里,关于ai伪api,如何用php调用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!