


PHP implementation method of Ping service to make the website quickly included_PHP tutorial
This article continues to talk about the problem of this ping service. First, we summarize and summarize the following information:
【1】Manual Ping service address:
Baidu (Baidu) address: http://ping.baidu.com/ping .html
Google address: http://blogsearch.google.com/ping
Feedsky address: http://ping.feedsky.com/ping.html
Qihoo( Qihoo) address: http://so.blog.qihoo.com/pingblog.html
IASK (爱 Ask) address: http://blog.iask.com/ping.php
【2】Automatic Ping Service Application Programming Interface (API):
Google: http://blogsearch.google.com/ping/RPC2
Feedburner: http://ping.feedburner.com
Feedsky ): http://www.feedsky.com/api/RPC2
Feedster: http://api.feedster.com/ping.php
IASK: http://blog.iask.com /RPC2
Qihoo (Qihoo): http://ping.blog.qikoo.com/rpc2.php
Fresh fruit: http://www.xianguo.com/xmlrpc/ping.php
Catch Shrimp: http://www.zhuaxia.com/rpc/server.php
Blogdigger: http://www.blogdigger.com/RPC2
blo.gs: http://ping.blo.gs/
ICEROCKEThttp://rpc.icerocket.com:10080/
Moreover: http://api.moreover.com/RPC2
Newsgator: http://rpc.newsgator.com/
Syndic8 : http://www.syndic8.com/xmlrpc.php
Weblogs: http://rpc.weblogs.com/RPC2
Weblogalot: http://ping.weblogalot.com/rpc.php
Among the ping services provided above, I have tried some that work well and some that don’t. It depends on the situation. You can test this yourself based on the network environment, etc., and the one that suits you is the best. There is no recommendation.
Okay, having said so much above, the following is the key point, that is, how to implement the ping service. WordPress can implement it through the background, what about the others? For example, what should I do if there is a blog program that does not have a ping service function? As far as Fenren knows, the easy-to-use wordpress in the blog system comes with a PING function. There is no doubt that the ASP-like Z-BLOG seems to be able to achieve this function through a plug-in. Other blogging systems? Others? There is nothing else, my only choice is wordpress, nothing else but the only one. Haha, no kidding. Let’s talk about the problem of using PHP to implement the ping service. This is for other websites or systems that do not support the ping function. You can develop an interface to implement it yourself. For example, the secondary development of DEDECMS can be used. Fenxun has been studying this project recently.
What needs to be said is that Baidu’s ping and Google’s submission formats are different. Let’s briefly talk about them and give an introduction to Baidu and Google respectively. The first introduction is Google (why not Baidu, OK? Don’t be so entangled , there will be...):
[*1] PHP implementation of Google's ping service
For a detailed introduction to RPC, you can go to Wikipedia, the standard of Google's ping service:
RPC endpoint: http ://blogsearch.google.com/ping/RPC2
Calling method name: weblogUpdates.extendedPing
Parameters: (should be sent in the same order as listed below)
Site name
Site URL
The URL of the page that needs to be checked for updates
The URL of the corresponding RSS, RDF or Atom seed
Optional: the category name (or tag) of the page content. You can specify multiple values, separated by '|' characters.
First, write a CURL function to POST Google's RPC endpoint:
function postUrl($url, $postvar) {
$ch = curl_init();
$headers = array(
"POST ".$url." HTTP/1.0″,
"Content- type: text/xml;charset="utf-8"",
"Accept: text/xml",
"Content-length: ".strlen($postvar)
);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
$res = curl_exec ($ch);
curl_close ($ch);
return $res;
}
After the main curl is written, the only thing left is to assemble the sent data according to Google’s XML-RPC standard. For detailed request examples, please refer to the official case, click here.
For example, my code is written like this:
$googleXML = <<
END;
$res = postUrl('http://blogsearch.google.com /ping/RPC2′, $googleXML);
//The following is the judgment of whether the return is successful or not (according to the interface description of Google ping)
if (strpos($res, "
else
echo "PING failed";
OK, this can simply implement Google's PING service. You can modify the code to implement this function.
[*2] PHP implementation of Baidu’s ping service (this title is really DT)
Baidu’s ping service xml code is different from Google’s. Baidu always has its own characteristics:
Introduction Baidu Blog Ping Service, for a detailed introduction to Baidu Blog Ping Service, please go to: http://www.baidu.com/search/blogsearch_help.html#n7.
Baidu's ping service is also based on the XML-RPC standard protocol, but what is different from Google's ping service is that the XML format sent by Baidu's ping is different. We need to use string nodes to wrap the content.
For example:
according to For the Google interface mentioned above, we only need to change the submitted xml content. Of course, the judgment returned by Baidu ping service is also different from Google's, and corresponding modifications can also be made.
The following is the PHP code:
$baiduXML = <<
EOT;
$res = postUrl('http://ping.baidu.com/ping/RPC2′, $baiduXML ; "PING successful";
else
echo "PING failed";
The above code can implement PHP's ping service. Okay, now I will provide you with a Baidu ping service code. Who makes it so unique?
Copy code
function postUrl($url, $postvar)
{
$ch = curl_init();
$headers = array(
"POST ".$url." HTTP/1.0″,
"Content-type: text/xml; charset="gb2312"",
"Accept: text/xml",
"Content-length: ".strlen($postvar)
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
$res = curl_exec ($ch);
curl_close ($ch);
return $res;
}
$baiduXML = "
$res = postUrl(‘http://ping.baidu.com/ping/RPC2′, $baiduXML);
if ( strpos($res, "
{
echo "PING成功";
}
else
{
echo "PING失败";
}
?>
此文很DT的让我浪费了N个草稿才写完,然后纷纭就发现需要搞个CODE的插件给WP装备上了。代码的问题真的很纠结,还有就是国人的WP主题没有支持分页的,这个让我很DT,说了半天,DT是啥?不知道……

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
