前面介绍了destoon7.0 百度收录自动提交的方法,今天一起来看看dedecms怎么做百度收录自动提交!
第一步:在plus ask目录下新建一个php文件,命名为xzh.php代码如下: require_once(dirname(__FILE__).'/https://blog.csdn.net/hhg2006/include/common.inc.php');
require_once(DEDEINC."/arc.partview.class.php");
require_once(dirname(__FILE__).'/https://blog.csdn.net/hhg2006/include/charset.func.php');
$year = date("Y");
$month = date("m");
$day = date("d");
$dayBegin = mktime(0,0,0,$month,$day,$year);
$dayEnd = mktime(23,59,59,$month,$day,$year);
$query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin."";
//echo $query;
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
$urls.="enbs.cn/en/".$row[id].".html".",";
}
$urls=substr($urls,0,-1);
$tjurl = $urls;
$urls = explode(",",$urls);
$api = '**********'; // 熊掌号api接口调用地址
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode(" ", $urls),
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;
$dsql->ExecuteNoneQuery("Update `#@__sys_task` set sta='成功' where dourl='xzh.php' ");
$jieguo = date('Y-m-d H:i:s',time())."返回结果:".$result." ".$tjurl;
$numbytes = file_put_contents('xzh.txt', $jieguo); //返回结果
exit();
第二步:在网站后台系统-计划任务管理里面新增一个任务,运行程序填xzh.php,设定好执行规则。 第三步:在模板中用JS调用/plus/task.php?client=js任务执行成功之后会在plus ask目录下生成一个xzh.txt文件,返回提交结果、任务执行时间、提交的url,如下图:
img
注意事项: 1.文章url规则需要根据自己网站的规则更改一下; 2.api接口调用地址需要改成自己的; 3.遇到问题可以咨询QQ:214875213(承接各种网站建设、cms二次开发、小程序开发等业务)相关网站: www.dicto.cn enbs.cn www.ruihongw.com,www.kz8.cn www.dazhe5.cn