这篇文章主要介绍了百度实时推送api接口应用示例,非常的实用,有需要的朋友可以参考下
网站质量不错的网站可以在百度站长平台/数据提交/sitemap栏目下看到实时推送的功能, 目前这个工具是邀请开放, 百度的实时推送的api接口可以实时推送我们新发布的文章, 保证百度在第一时间收录.
百度站长平台
打开百度站长平台, 点开实时推送的添加新数据接口获得带token的api推送地址:
分享一段网友写的php实时推送代码:
php 实时推送新发布的文章
socketopen方式推送sitemap
复制代码 代码如下:
function sitemap_ping_baidu($urls){
$baidu_ping_url = 'ping.baidu.com';
$get = '/sitemap?site=www.yourdomain.com&resource_name=sitemap&access_token=xxxxxxx';
$port=80;
if ( ( $io = fsockopen( $baidu_ping_url, $port, $errno, $errstr, 50 ) ) !== false ) {
$send = "POST $get HTTP/1.1"."rn";
$send .= 'Accept: */*'."rn";
$send .= 'Cache-Control: no-cache'."rn";
$send .= 'Host: '.$baidu_ping_url."rn";
$send .= 'Pragma: no-cache'."rn";
//$send .= "Referer: ".$url.$get."rn";
//$send .= 'User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)'."rn";
$xml = '
foreach($urls as $url){
$xml .= '
$xml .= '
$xml .= '
$xml .= '
$xml .= '
$xml .= '
}
$xml .= '
$send .= 'Content-Length:'.strlen($xml)."rn";
$send .= "Connection: Closernrn";
$send .= $xml."rn";
fputs ( $io, $send );
$return = '';
while ( ! feof ( $io ) )
{
$return .= fread ( $io, 4096 );
}
return $return;
}else{
return false;
}
}
$return = sitemap_ping_baidu(array('http://www.yourdomain.com/a.php?id=1'));
推送后百度会返回的xml文档
复制代码 代码如下:
状态码含义如下
200 无使用方式错误,需要进一步观察返回的内容是否正确
400 必选参数未提供
405 不支持的请求方式,我们只支持POST方式提交数据
411 HTTP头中缺少Content-Length字段
413 推送的数据过大,超过了10MB的限制
422 HTTP头中Content-Length声明的长度和实际发送的数据长度不一致
500 站长平台服务器内部错误
,
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.