求助 版主:官方研发技术组
我按照火车头采集内容制作的脚本为什么发布不成功呢我是这样做的
类型:迅睿CMS 更新时间:2021-01-08 11:10:47 火车头 发布

我按照火车头采集内容制作的脚本  为什么发布不成功呢 我是这样做的  

{xunruicms_img_title}{xunruicms_img_title}

代码的内容 是这样的

<?php

/**
 * 数据采集
 */

define('IS_API', basename(__FILE__, '.php')); // 项目标识
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); // 该文件的名称
require('../index.php'); // 引入主文件
<?php


$this->_module_init('news'); // news 是模块目录

if ($_GET['action'] == 'category') {
    // 显示栏目

    foreach ($this->module['category'] as $t) {
        if ($t['child'] == 0 && $t['tid'] == 1) {
            echo '<h1>'.$t['name'].'<=>'.$t['id'].'</h1>'.PHP_EOL;
        }
    }

} else {
    // 入库数据

    $data = $_REQUEST;

    // 发布者id 1
    $data['uid'] = 1;

    // 发布者账号 admin
    $data['author'] = 'admin';

    // 主表字段
    $fields[1] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR));
    $cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data'));
    $cache && $fields[1] = array_merge($fields[1], $cache);

    // 附表字段
    $fields[0] = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_data_0'));
    $cache = $this->get_cache('table-'.SITE_ID, $this->content_model->dbprefix(SITE_ID.'_'.MOD_DIR.'_category_data_0'));
    $cache && $fields[0] = array_merge($fields[0], $cache);

    // 去重复
    $fields[0] = array_unique($fields[0]);
    $fields[1] = array_unique($fields[1]);

    $save = [];

    // 主表附表归类
    foreach ($fields as $ismain => $field) {
        foreach ($field as $name) {
            isset($data[$name]) && $save[$ismain][$name] = $data[$name];
        }
    }
        if (!$data['catid']) {
            exit('栏目为空');
        }

    $save[1]['uid'] = $save[0]['uid'] = $data['uid'];
    $save[1]['catid'] = $save[0]['catid'] = $data['catid'];

    $save[1]['url'] = '';
    $save[1]['status'] = 1; //9表示正常发布,1表示审核里面
    $save[1]['hits'] = 0;
    $save[1]['displayorder'] = 0;
    $save[1]['link_id'] = 0;
    $save[1]['inputtime'] = $save[1]['updatetime'] = SYS_TIME + rand(0, 7200);
    $save[1]['inputip'] = '127.0.0.1';

    // 验证标题重复
    if ($this->content_model->table(SITE_ID.'_'.MOD_DIR)->where('title', $save[1]['title'])->counts()) {
        echo '重复';exit;
    }


    $rt = $this->content_model->save_content(0, $save);

    if ($rt['code']) {
        exit('成功');
    } else {
        exit('失败');
    }

}

exit;


回帖
  • 官方研发技术-西门
    #1楼    官方研发技术-西门
    2021-01-08 10:18:19
    Chrome 0
    写法没有问题,发布不成功提示什么错误,看看结果
  • 晓猛seo
    #2楼    晓猛seo
    2021-01-08 10:26:27
    Chrome 0
    官方研发技术-西门
    发布失败,错误信息:
    
    网页源代码:
    
    返回的Header:
    HTTP/1.1 500 Internal Server Error
    Server:nginx
    Content-Type:text/html; charset=UTF-8
    Transfer-Encoding:chunked
    Connection:keep-alive
    Cache-control:no-store, max-age=0, no-cache
    Date:Fri, 08 Jan 2021 02:25:24 GMT
    Content-Length:0
  • 官方研发技术-西门
    #3楼    官方研发技术-西门
    2021-01-08 10:37:46
    Chrome 0
    500错误是习惯故障,你看看,系统-日志管理-错误日志
  • 晓猛seo
    #4楼    晓猛seo
    2021-01-08 10:40:36
    Chrome 0
    官方研发技术-西门
    <?php defined('SYSTEMPATH') || exit('No direct script access allowed'); ?>
    
    ERROR - 2021-01-08 09:31:33 --> BaiduApiToken:
    ERROR - 2021-01-08 09:38:17 --> BaiduApiToken:
    ERROR - 2021-01-08 09:38:52 --> http://wz.entem.cn/index.php?s=member:模板文件不存在(/wwwroot/xunruiCMS/template/pc/newmoban/member/header.html)
    ERROR - 2021-01-08 09:45:28 --> BaiduApiToken:
    ERROR - 2021-01-08 09:45:55 --> BaiduApiToken:
    ERROR - 2021-01-08 09:47:58 --> BaiduApiToken:
    ERROR - 2021-01-08 09:56:15 --> BaiduApiToken:
    CRITICAL - 2021-01-08 10:25:24 --> Call to undefined method Phpcmf\Model\Content::save_content()
    #SQL:SELECT COUNT(*) AS `numrows` FROM `dr_1_news` WHERE `title` = '你好'
    #URL:http://wz.entem.cn/api/caiji.php?action=post
    #AGENT:
    #REFERER:http://wz.entem.cn/
    #0 /wwwroot/xunruiCMS/dayrui/Core/Controllers/Api/Home.php(35): require()
    #1 /wwwroot/xunruiCMS/dayrui/System/CodeIgniter.php(918): Phpcmf\Controllers\Api\Home->index()
    #2 /wwwroot/xunruiCMS/dayrui/System/CodeIgniter.php(404): CodeIgniter\CodeIgniter->runController()
    #3 /wwwroot/xunruiCMS/dayrui/System/CodeIgniter.php(312): CodeIgniter\CodeIgniter->handleRequest()
    #4 /wwwroot/xunruiCMS/dayrui/Fcms/Init.php(377): CodeIgniter\CodeIgniter->run()
    #5 /wwwroot/xunruiCMS/index.php(50): require('/wwwroot/xunrui...')
    #6 /wwwroot/xunruiCMS/api/caiji.php(9): require('/wwwroot/xunrui...')
    #7 {main}
  • 官方研发技术-西门
    #5楼    官方研发技术-西门
    2021-01-08 10:49:41
    Chrome 0
    程序版本低了,需要4.3.13,函数不支持了
    满意答案
  • 阿赖耶识
    #6楼    阿赖耶识
    2021-01-08 10:52:20
    Chrome 0
    cms框架版本低了
  • 晓猛seo
    #7楼    晓猛seo
    2021-01-08 11:10:47
    Chrome 0
    @官方研发技术-西门:ok 解决了 ok 解决了