Home Backend Development PHP Tutorial PHP implementation method of Ping service to make the website quickly included_PHP tutorial

PHP implementation method of Ping service to make the website quickly included_PHP tutorial

Jul 21, 2016 pm 03:21 PM
php ping accomplish fast included article method Serve of website Talk about it this question

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:

Copy the code The code is as follows:

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:
Copy the code The code is as follows:

$googleXML = <<

weblogUpdates.extendedPing


PHP implementation method of Ping service, so that the website can be included quickly


http://s.jb51.net


http:/ /s.jb51.net/archives/47.html


http://s.jb51.net/feed< /value>



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, "0echo "PING successful";
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:
Copy code The code is as follows:



weblogUpdates.extendedPing


< string>PHP implementation method of Ping service, allowing the website to be included quickly


http://s.jb51.net/


http:// s.jb51.net/archives/47.html


http:// s.jb51.net/feed




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:
Copy code The code is as follows:

$baiduXML = <<

weblogUpdates.extendedPing

PHP implementation method of Ping service, allowing the website to be included quickly
http:// s.jb51.net
http://s.jb51.net/archives/47.html< /string>
http://s.jb51.net/feed< /param>


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
The code is as follows:

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 = "

weblogUpdates.extendedPing

脚本之家
http://www.jb51.net
http://www.jb51.net/a/15222.html
http://www.jb51.net

";
$res = postUrl(‘http://ping.baidu.com/ping/RPC2′, $baiduXML);
if ( strpos($res, "0") )
{
echo "PING成功";
}
else
{
echo "PING失败";
}
?>

此文很DT的让我浪费了N个草稿才写完,然后纷纭就发现需要搞个CODE的插件给WP装备上了。代码的问题真的很纠结,还有就是国人的WP主题没有支持分页的,这个让我很DT,说了半天,DT是啥?不知道……

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/324871.htmlTechArticle这篇文章继续说说这个ping服务的问题,首先归纳和总结以下资料: 【1】手动Ping服务地址: Baidu(百度)地址: http://ping.baidu.com/ping.html Goog...
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

Video Face Swap

Video Face Swap

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

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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

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

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

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

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

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

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

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 PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

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.

See all articles