Weblog_Pinger: Update Notification PHP Library

Weblog_Pinger is a PHP class library that can send update notification pings over XML-RPC services such as Weblogs.Com, Ping-o-Matic and Technorati and PubSubHubbub services that use REST.

After it is installed, you can use it by creating a Weblog_Pinger object and calling one of its ping methods:

require('weblog_pinger.php');
$pinger = new Weblog_Pinger();
$pinger->ping_ping_o_matic("Ekzemplo", "http://www.ekzemplo.com/");

Links:

This software was developed by Rogers Cadenhead, publisher of the Workbench weblog, with help from David Sifry of Technorati. It has been released under the GNU General Public License.

I'm running the software on PHP 5.2.10 and MySQL 5.1. I think it should work with PHP 4 or higher and MySQL 3.2 or higher.

Copyright 2009 Rogers Cadenhead

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Installation instructions
  • Download the Weblog_Pinger archive in zip format and unpack the archive.

  • Save the PHP class library weblog_pinger.php in a directory where it will be accessible to PHP Web pages. I put it in the software's include_path directory, which is often /usr/local/lib/php on new installations.

  • Open the PHP script weblog_pinger_install.php in a text editor and edit the file to identify the MySQL database where ping attempts will be tracked. Use the , , and variables to access the database that will hold the pingcheck database. Save the script in a web-accessible directory.

  • Install the XML-RPC for PHP library in a subdirectory of PHP's include directory called xmlrpc or edit the require_once statement in weblog_pinger.php to indicate the location of the file xmlrpc.inc.

  • To create the database table for Weblog-Pinger, after giving a MySQL user access to the pingcheck database using a grant all statement (or your MySQL database's management software), open the PHP script weblog_pinger_install.php in a web browser. After you verify that the database table has been created successfully, delete weblog_pinger_install.php.
Documentation

The following methods are available:

  • ping_weblogs_com($weblog_name, $weblog_url, $changes_url = "", $category = "")

  • ping_blo_gs($weblog_name, $weblog_url, $changes_url = "", $category = "")

  • ping_technorati($weblog_name, $weblog_url, $changes_url = "", $category = "")

  • ping_audio_weblogs_com($weblog_name, $weblog_url, $changes_url = "", $category = "")

  • ping_ping_o_matic($weblog_name, $weblog_url, $changes_url = "", $category = "")

  • ping_simplaris_blogcast($weblog_name, $weblog_url, $ping id, $changes_url = "", $category = "")

  • ping_all($weblog_name, $weblog_url, $changes_url = "", $category = ""), ping Weblogs.Com, Ping-O-Matic, and Technorati

  • ping_feedburner($weblog_name, $weblog_url, $changes_url = "", $category = "")

  • ping_weblogs_com_extended($weblog_name, $weblog_url, $changes_url, $rss_url)
  • ping_rest($updated_urls, $ping_server)

Most of these methods take the following four arguments, two of which are optional and may be omitted:

  • weblog_name: the name of the weblog that has been updated

  • weblog_url: the URL of the weblog

  • changes_url: the URL of a page to be checked for changes (default: use the weblog_url)

  • category: the category to which the ping should be submitted (default: none)

The ping_weblogs_com_extended() method takes four required arguments: weblog_name, weblog_url, changes_url, and rss_url, the URL of the weblog's RSS feed.

The ping_simplaris_blogcast() method takes one additional argument, ping_id, a user-specific ID generated by Simplaris Blogcast when you add the application to your Facebook profile. The ID can be found on your ping info page for the application. The ID is the alphanumeric code that follows "http://blogcast.simplaris.com/ping/" in the ping URL.

With the exception of ping_all(), these methods return true on success and false on failure. Errors are reported on the PHP error log.

The ping_all() method returns an array containing two elements: a boolean for the success of the whole method and an array with booleans returned by the method calls to ping_technorati(), ping_weblogs_com(), and ping_ping_o_matic().

There's also a method for other notification services that support the Weblogs.Com XML-RPC interface, but you have to know more about the service:

  • ping($xml_rpc_server, $xml_rpc_port, $xml_rpc_path, $xml_rpc_method, $weblog_name, $weblog_url, $changes_url, $category)

The ping_rest() method takes two arguments: a string or array of strings with the URLs of RSS feeds that have been updated and the URL of a PubSubHubbub hub. The second argument is optional. If omitted, the hub at http://pubsubhubbub.appspot.com is used.

Additional method arguments:

  • xml_rpc_server: the host name of the XML-RPC server

  • xml_rpc_port: the server's port number (usually 80)

  • xml_rpc_path: the path to use for XML-RPC requests (often /RPC2)

  • xml_rpc_method: the name of the ping method

Logging:

This class can log all ping requests, responses, and the associated XML data. Here's an example:

Request: weblogUpdates.ping("Ekzemplo", "http://www.ekzemplo.com/")
<?xml version="1.0"?>
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param>
<value><string>Ekzemplo</string></value>
</param>
<param>
<value><string>http://www.ekzemplo.com/</string></value>
</param>
</params>
</methodCall>

<value><struct>
<member><name>flerror</name>
<value><boolean>0</boolean></value>
</member>
<member><name>message</name>
<value><string>Thanks for the ping.</string></value>
</member>
</struct></value>

Set the class variable $log_file to the path and name of the log file.

Set the variable $log_level to one of three values: 'none' (no logging), 'short' (everything but XML data), and 'full' (everything).

  • Version 1.6: Added support for PubSubHubbub, Sept. 17, 2009

  • Version 1.5: Added support for the Facebook application Simplaris Blogcast, Feb. 15, 2009

  • Version 1.4: Stored pings in a MySQL database to prevent ping servers from being hit too often, Sep. 19, 2007

  • Version 1.3: Added support for logging, Oct. 11, 2005

  • Version 1.2: Added support for the new extended ping of Weblogs.Com, April 28, 2005

  • Version 1.1: Added support for Audio.Weblogs.Com, Jan. 30, 2005

  • Version 1.0: Original release, Jan. 10, 2005