Home Backend Development PHP Tutorial 百度ping服务的php兑现以及google ping服务

百度ping服务的php兑现以及google ping服务

Jun 13, 2016 pm 01:19 PM
gt lt param ping

百度ping服务的php实现以及google ping服务
百度ping服务的php实现:

$baiduXML = 
	<methodcall>
	<methodname>weblogUpdates.extendedPing</methodname>
	<params>
	<param><value><string>小桔灯分类信息网</string></value>
	<param><value><string>http://www.xiaojudeng.com</string></value>
	<param><value><string>www.xiaojudeng.com</string></value>
	<param><value><string>http://www.xiaojudeng.com/sitemaps.xml</string></value>
	</params>
	</methodcall>
EOT;
$res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML);
//下面是返回成功与否的判断(根据百度ping的接口说明)
if (strpos($res, "<int>0</int>"))
        echo "PING成功";
    else
        echo "PING失败";
Copy after login


google ping服务代码:
$googleXML = 
<methodcall>
  <methodname>weblogUpdates.extendedPing</methodname>
  <params>
    <param>
      <value>小桔灯分类信息网</value>
    
    <param>
      <value>http://www.xiaojudeng.com</value>
    
    <param>
      <value>http://www.xiaojudeng.com</value>
    
    <param>
      <value>http://www.xiaojudeng.com/sitemaps.xml</value>
    
  </params>
</methodcall>
END;
$res = postUrl('http://blogsearch.google.com/ping/RPC2', $googleXML);
//下面是返回成功与否的判断(根据谷歌ping的接口说明)
if (strpos($res, "<boolean>0</boolean>"))
        echo "PING成功";
    else
        echo "PING失败";
Copy after login


postUrl函数代码如下:
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;
}
Copy after login

转载自 http://www.js8.in/644.html
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)

How to fix Xbox Series S/X download speeds, reduced ping and lag How to fix Xbox Series S/X download speeds, reduced ping and lag Apr 16, 2023 pm 04:49 PM

Xbox consoles have improved dramatically over the years. Over the years, games have evolved with life-like features that gamers can't seem to get enough of. Playing your favorite games on Xbox can be a completely engrossing experience. However, sometimes using these advanced features, we end up with lag or ping issues if the internet speed is not that good. Sometimes we want games to download faster. Today, games like Forza Horizon 5 and Mortal Kombat require over 100GB of RAM. Downloading such games can take a long time if we don't have the right internet settings to help us. Method 1: Pass

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

What is the reason for the ping request timeout? What is the reason for the ping request timeout? Aug 28, 2023 pm 04:17 PM

The reasons for the ping request timeout include unreachable target host, network congestion, firewall or security settings, and DNS resolution issues. Detailed introduction: 1. The target host is unreachable. The Ping request timeout may mean that the target host cannot be accessed through the network. This may be due to the target host closing the network connection, the network where the target host is located failing, the target host IP address being set incorrectly, etc. ; 2. Network congestion. Ping request timeout may also be caused by network congestion. Network congestion may be due to large amounts of data transmission, network equipment failures, etc.

Why can't I ping the gateway? Why can't ping? Why can't I ping the gateway? Why can't ping? Mar 13, 2024 pm 03:40 PM

The network cannot ping, what's going on? In fact, this is a very common problem. It is mainly divided into two situations: pinging fails on the same network segment and pinging fails on different network segments. Let’s take a look at the details below. There are usually two reasons why the ping command cannot connect to the same network segment: one is an IP address that cannot be pinged in the same network segment, and the other is an IP address that cannot be pinged in a different network segment. These two situations have different solutions. First, let’s discuss the situation where ping fails within the same network segment. 1. Ping fails on the same network segment, and the result is "Unable to access the target host." The destination IP and source IP are on the same network segment, and the ping result is &l

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

How to solve the error message 'ping is not recognized as an internal or external command or an operable program' How to solve the error message 'ping is not recognized as an internal or external command or an operable program' Feb 22, 2023 pm 04:28 PM

Solution: 1. Click the "Start" button, click "Control Panel" - "System" in the start menu; 2. In the settings interface, click "Advanced System Settings" - "Advanced" - "Environment Variables"; 3. . Check whether there is a Path variable in Administrator's user variables. If you do not see this variable, click "New" and add the variable Path and variable value.

What are the reasons why the IP address cannot be pinged? What are the reasons why the IP address cannot be pinged? Dec 15, 2020 pm 04:37 PM

The reasons why the IP address cannot be pinged are: 1. The other party is shut down or the IP address does not exist; 2. The network segment is different and cannot be found through routing; 3. The firewall filters the ICMP packets sent by ping; 4. The IP address is set incorrectly; 5. Network cable failure; 6. The gateway is not set.

The ttl value of ping briefly determines the operating system categories. The ttl value of ping briefly determines the operating system categories. May 22, 2023 am 09:04 AM

The type of some operating systems can often be roughly judged by the ttl value of ping. Here is a summary: The TTL field value of the ICMP echo response of UNIX and UNIX-like operating systems is 255. CompaqTru645.0 The TTL field value of the ICMP echo response is 64. The TTL field value of the ICMP echo response of the Microsoft Windows NT/2K operating system is 128. The TTL field value of the ICMP echo response of the Microsoft Windows 95 operating system is 32. Of course, these ttl values ​​can also be changed. Windows series systems can modify the following key values ​​in the registry. Implementation: [HKEY_LOCAL_MACHINE\system\Curren

See all articles