Workbench: Programming, Publishing, Politics, and Popes

Subscriptions

Menu

Working On

Technorati

XFN Friendly

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.

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 4.3.2 and MySQL 3.23. I think it should work with PHP 4 or higher and MySQL 3.2 or higher.

Copyright 2007 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 either tar.gz or 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_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)

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.

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)

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

  • 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

  • category: the category to which the ping should be submitted

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).

Twitter

Updating servers with Curl 7.19.2, a quick release to correct some fubar mistakes in 7.19.1 released two weeks ago. about 5 hours ago






Home | Comments | Books | Code | RSS Feed | RSS Spec | Copyright 2008 World Readable