PHP实现博客Ping功能源码分享

什么是Ping

Ping 是一种服务php

经过Ping,你能够通知搜索引擎来快速收录你的博客git

Ping使用的是XML-RPC格式github

如何Ping

Ping有两种方式,手动的和自动的web

使用PHP自动Ping

原理很简单。经过第三方提供的类IXR_Library.php 造成XML-RPC格式的数据发送到各大网站的Ping地址便可post

demo.php网站

require ("IXR_Library.php");

function xmlRpcPing($url, $title, $urlIndex, $url_key, $rss)
{

    $client = new IXR_Client($url);
    $client->timeout = 3;
    $client->useragent .= ' -- Shop123 Ping/2.0.0';
    $client->debug = false;

    if ($client->query('weblogUpdates.extendedPing', $title, $urlIndex, $url_key, $rss)) {
        return $client->getResponse();
    }

    if ($client->query('weblogUpdates.ping', $title, $urlIndex, $url_key)) {
        return $client->getResponse();
    }

    return false;
}

$title = "title";
$urlIndex = "http://yourblog.com/";
$url_key = "http://yourblog.com/postid";
$rss = "http://yourblog.com/feed";

xmlRpcPing('http://blogsearch.google.com/ping/RPC2', $title, $urlIndex, $url_key, $rss);

参数:ui

  • title是博客的标题搜索引擎

  • urlIndex是博客首页地址google

  • url_key是博客的具体地址url

  • rss是订阅源feed地址 能够不填

  • http://blogsearch.google.com/... 是Google Ping的地址其中之一,还有不少这里没有都列出

源码地址: https://github.com/maketea/ping

手动Ping

Google:http://blogsearch.google.com/...

百度:http://utility.baidu.com/blog...

因为这些地址有不少都过时了,这里就不一一列出了

相关文章
相关标签/搜索