Table of Contents
织梦sitemap地图实时推送给百度的教程,织梦sitemap
Home php教程 php手册 织梦sitemap地图实时推送给百度的教程,织梦sitemap

织梦sitemap地图实时推送给百度的教程,织梦sitemap

Jun 13, 2016 am 08:56 AM
real time push dream weaving

织梦sitemap地图实时推送给百度的教程,织梦sitemap

在之前,织梦有一套自己主动ping百度的插件,但是后来用不了了,最后百度推出了实时推送链接地址到百度,这样要比sitemap方便好用多了,而且还能保证文章的原创,下面我通过查阅相关资料,根据百度的接口写了一篇sitemap地图实时推送给百度的处理办法,分享给大家。

关于织梦的百度实时推送我写了两种方法,大家可以自行选择:

1.手动创建一个文件,每天访问这个文件就可以把当天的全部文章推送到百度搜索引擎. 在根目录下面创建一个tuisong.php  访问后会返回百度接口结果

<&#63;php
require_once ("include/common.inc.php");
require_once "include/arc.partview.class.php";
require_once('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.""; //这里dede换成你们自己的表前缀
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
 $urls.="http://www.baidu.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; 
 //将上边的http://baidub.com换成你的网址
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls&#63;site=www.baidu.com&token=hereistoken'; // 前边的site换成自己的site xxx换成自己的密钥
$ch = curl_init();
$options = array(
 CURLOPT_URL => $api,
 CURLOPT_POST => true,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_POSTFIELDS => implode("\n", $urls),
 CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result.count($urls);
&#63;>
Copy after login

查看推送反馈

推送成功

状态码为200,可能返回以下字段:
字段 是否必选 参数类型 说明
success 是 int 成功推送的url条数
remain 是 int 当天剩余的可推送url条数
not_same_site 否 array 由于不是本站url而未处理的url列表
not_valid 否 array 不合法的url列表
成功返回示例:

复制代码 代码如下:
{
"remain":4999998,
"success":2,
"not_same_site":[],
"not_valid":[]
}

推送失败

状态码为4xx,返回字段有:
字段 是否必传 类型 说明
error 是 int 错误码,与状态码相同
message 是 string 错误描述
失败返回示例:

复制代码 代码如下:
{
"error":401,
"message":"token is not valid"
}

2、第二种是发布一篇文章,就像百度推送一次,这种比较方便,我就是用这种

打开织梦后台的 article_add.php 文件.找到差不多262行的样子

注意:
如果你系统设置的-》核心选项

如果是否直接. 加入以下代码,否则 注意下面的提示

//百度推送
$urls="http://www.baidu.com".$artUrl;//前面域名换成你自己的 如果上面图片选择的是是 就把"http://baidu.com". 去掉
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls&#63;site=www.0cx.cc&token=hereistoken'; // 前边site换成自己的site xxx换成自己的密钥
$ch = curl_init();
$options = array(
 CURLOPT_URL => $api,
 CURLOPT_POST => true,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_POSTFIELDS => implode("\n", $urls),
 CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
Copy after login

就OK了  ,如果想看添加成功没,可以在修改下面一两行的样子的代码

复制代码 代码如下:
请选择你的后续操作".$result.$urls[0].":

result是看百度返回的结果,urls是看你推送的url.

基本上就OK了,如果你想让修改文章的时候也事实推送,就类似我上面一样去修改article_edit.php就好了.

以上就是本文的全部内容,希望大家喜欢。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

UniApp implements real-time push techniques for push messages and notifications UniApp implements real-time push techniques for push messages and notifications Jul 04, 2023 am 11:34 AM

UniApp implements real-time push techniques for push messages and notifications In modern society, the push message and notification functions of mobile applications are becoming more and more important. As users have higher and higher demands for real-time information, developers are constantly exploring how to implement real-time push in mobile applications. As a cross-platform development framework, UniApp provides developers with a simple and efficient way to implement real-time push messages and notifications. UniApp is a cross-platform development framework developed based on Vue.js. It supports the integration of a set of codes into

How to implement real-time data push function in MongoDB How to implement real-time data push function in MongoDB Sep 21, 2023 am 10:42 AM

How to implement real-time data push function in MongoDB MongoDB is a document-oriented NoSQL database, which is characterized by high scalability and flexible data model. In some application scenarios, we need to push data updates to the client in real time in order to update the interface or perform corresponding operations in a timely manner. This article will introduce how to implement the real-time push function of data in MongoDB and give specific code examples. There are many ways to implement real-time push functionality, such as using polling, long polling, Web

Java development: How to use WebSocket to implement real-time push function Java development: How to use WebSocket to implement real-time push function Sep 20, 2023 am 09:09 AM

Java Development: Using WebSocket to Implement Real-Time Push Function Introduction: In modern web applications, the transmission of real-time data is becoming more and more important. WebSocket is a protocol that provides two-way real-time communication between client and server, which can transfer data without refreshing the page. This article will introduce how to use Java language and Spring framework to implement real-time push function through WebSocket, and provide specific code examples. Environment preparation: First, we need to build J

How to import css in DreamWeaver How to import css in DreamWeaver Dec 03, 2020 pm 04:03 PM

How to import css into DreamWeaver: 1. Place the HTML template file in the "templets" folder; 2. Change the suffix of the HTML file to ".htm"; 3. Add "{dede:" in front of the original style path: global.cfg_templets_skin/}" can be used.

PHP WebSocket development technology sharing: the best strategy to implement real-time push function PHP WebSocket development technology sharing: the best strategy to implement real-time push function Sep 11, 2023 pm 01:24 PM

PHPWebSocket development technology sharing: The best strategy to implement real-time push function With the rapid development of the Internet and the gradual increase in user demand for real-time information, real-time push has become an indispensable part of modern Web applications. As an open standard, WebSocket technology provides a two-way communication capability, making it an ideal choice for realizing real-time push functions. This article will share some of the best strategies for PHP WebSocket development to help developers implement real-time push functions quickly and efficiently.

How to use Vue and Axios to achieve real-time push and update of data How to use Vue and Axios to achieve real-time push and update of data Jul 17, 2023 am 08:58 AM

How to use Vue and Axios to achieve real-time push and update of data Introduction: In modern web applications, real-time data push and update has become a common requirement. As a popular front-end framework, Vue can easily interact with the back-end for data interaction and real-time updates. Axios is a Promise-based HTTP library that can easily send asynchronous requests. This article will introduce how to use Vue and Axios to achieve real-time push and update of data. 1. Overview of realizing real-time push of data and

Decryption of real-time push and message broadcast technology of swoole development function Decryption of real-time push and message broadcast technology of swoole development function Aug 04, 2023 pm 01:57 PM

Decryption of real-time push and message broadcast technology developed by Swoole With the rapid development of the Internet, real-time push and message broadcast technology play an increasingly important role in various network applications. Swoole, as an efficient and development-friendly PHP extension, provides developers with powerful real-time communication capabilities. This article will introduce the real-time push and message broadcast technology in Swoole development functions, and provide some code examples. What is Swoole? Swoole is a coroutine concurrent network based on PHP language

Detailed explanation of CMS database file recovery method Detailed explanation of CMS database file recovery method Mar 13, 2024 pm 03:15 PM

The database is the core of website operation and stores important information such as user data and article content. Therefore, the backup and recovery of database files is particularly important during website operation. For websites built using Dreamweaver CMS, the recovery of database files is also a critical task. This article will introduce in detail the recovery method of Dreamweaver CMS database files, and provide specific code examples to help users quickly restore website data and ensure the normal operation of the website. 1. Back up the database file. Before restoring the database file, you first need to ensure that it has been

See all articles