Welcome to Geeklog, Anonymous Wednesday, April 24 2024 @ 01:57 am EDT

Geeklog Forums

Ping Feedburner on Story Post


shinji

Anonymous
What is the best way to go about this? I would like this to happen automatically if at all possible so I don't even have to think about it.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
FWIW, the next Geeklog release will support pinging services like Feedburner (although probably not as automatic as you may wish). And no, there's no release date yet ...

In the meantime, I know that some people created their own solutions by getting the source to ping such a service from a source repository on the web and wrap it into a PHP block or a static page.

bye, Dirk
 Quote

shinji

Anonymous
Well I got the automatic update that I wanted finally. Did some hacking around and used some code so here goes. This codes is taylored to pinging feedburner but can be modified for just about any site as long as you know their ping address. I will let you know what needs changed to make it work. Feedburner doesn't return a response when it works. If it returns something then something went wrong (unless that response is OK or something along those lines)

In story.php FIND:
Text Formatted Code

DB_save

 

It should be the first one you come across.
After that INSERT:
Text Formatted Code

        if ( $draft_flag == 0 )
        {
          $pingOutput = pingWeblogs($_CONF['site_name'], $_CONF['site_url']);
          COM_errorLog($pingOutput, 1);  
        }        

 


In lib-custom.php APPEND to end of file:
Text Formatted Code

<?
 //==============================================================================
 // A quick and dirty PHP function to update Weblogs.com
 // ----------------------------------------------------
 // Last Updated: 24 October 2001
 // Author: Matt Bean
 // Email : bean@yaysoft.com
 //
 // Description:
 // This file contains a single function: pingWeblogs() which has two optional
 // arguments - the name of the weblog, and the URL for the weblog, respectively.
 // Should these arguments be omitted, the values contained in the variables
 // $default_name and $default_url will be used as the values for the weblog name
 // and the weblog URL, respectively. The function returns the text message that
 // weblogs.com sends back. You will note that I do not use any fancy libraries,
 // just simple port communications and string truncation, but it works (at least
 // until weblogs.com feels like changing formats again).
 //
 // Use:
 // You may copy this code and place it in a PHP script of your choice, the only
 // values you should need to change are the $default_name and $default_url
 // variables.
 // Here is a quick example:
 //    $result = pingWeblogs("Blog Name", "http://blogurl.com/");
 //    echo "<b>Weblogs.com says</b>: $result";
 //
 // DISCLAIMER:
 // There are NO WARRANTIES, expressed or implied, regarding the use of this
 // code. Matt Bean cannot be held responsible for anything you do with this
 // code and any problems it may cause you or anyone else, either directly or
 // indirectly. Having said that, it's just a stupid little function, and it
 // really shouldn't be able to cause any harm, but I have to cover my bases.
 //
 // Peace, love, and good Karma!
 //==============================================================================    

 function pingWeblogs($name="", $url="") {

   global $_CONF;

  if (!$name) $name = $_CONF['site_name'];
  if (!$url)  $url  = $_CONF['site_url'];    


   $fp = fsockopen("ping.feedburner.com", 80, &$errnum, &$errstr);
   $output = "feedburner.com\n";
   if(!$fp) {
     echo "$errstr ($errnum)<br>\n";
     $output = "ERROR!";
   } else  {
     $len = strlen($name) + strlen($url) + strlen("<?xml version=\"1.0\"?><methodCall><methodName>weblogUpdates.ping</methodName><params><param><value></value></param><param><value></value></param></params></methodCall>");
     fputs($fp,"POST / HTTP/1.0\r\n");
     fputs($fp,"Host: ping.feedburner.com\r\n");
     fputs($fp,"User-Agent: Bean's Weblogs.com Updater (PHP Stylin')\r\n");
     fputs($fp,"Content-Type: text/xml\r\n");
     fputs($fp,"Content-length: $len\r\n\r\n");
     fputs($fp,"<?xml version=\"1.0\"?><methodCall><methodName>weblogUpdates.ping</methodName><params><param><value>$name</value></param><param><value>$url</value></param></params></methodCall>");        
     $output="";
     while(!feof($fp)) $output.=fgets($fp,4096);
     fclose($fp);        
   }

   $output = preg_replace("/.*<\/boolean>/si","",$output);
   $output = preg_replace("/.*<value>/si","",$output);
   $output = preg_replace("/<\/value>.*/si","",$output);          
   return $output;
 }
?>

 

This came thanks to some people who I don't recall that I got it from. This code was derived off a combination of the original code which I located and a modified version that I found on a bug report or something relating to geeklog.

To have it ping another site, change the parts in bold as you can see below. The item in italic is purely cosmetic and can be changed to anything you want.

//==============================================================================
// A quick and dirty PHP function to update Weblogs.com
// ----------------------------------------------------
// Last Updated: 24 October 2001
// Author: Matt Bean
// Email : bean@yaysoft.com
//
// Description:
// This file contains a single function: pingWeblogs() which has two optional
// arguments - the name of the weblog, and the URL for the weblog, respectively.
// Should these arguments be omitted, the values contained in the variables
// $default_name and $default_url will be used as the values for the weblog name
// and the weblog URL, respectively. The function returns the text message that
// weblogs.com sends back. You will note that I do not use any fancy libraries,
// just simple port communications and string truncation, but it works (at least
// until weblogs.com feels like changing formats again).
//
// Use:
// You may copy this code and place it in a PHP script of your choice, the only
// values you should need to change are the $default_name and $default_url
// variables.
// Here is a quick example:
// $result = pingWeblogs("Blog Name", "http://blogurl.com/");
// echo "Weblogs.com says: $result";
//
// DISCLAIMER:
// There are NO WARRANTIES, expressed or implied, regarding the use of this
// code. Matt Bean cannot be held responsible for anything you do with this
// code and any problems it may cause you or anyone else, either directly or
// indirectly. Having said that, it's just a stupid little function, and it
// really shouldn't be able to cause any harm, but I have to cover my bases.
//
// Peace, love, and good Karma!
//==============================================================================

function pingWeblogs($name="", $url="") {

global $_CONF;

if (!$name) $name = $_CONF['site_name'];
if (!$url) $url = $_CONF['site_url'];


$fp = fsockopen("ping.feedburner.com", 80, &$errnum, &$errstr);
$output = "feedburner.comn";
if(!$fp) {
echo "$errstr ($errnum)
n";
$output = "ERROR!";
} else {
$len = strlen($name) + strlen($url) + strlen("weblogUpdates.ping");
fputs($fp,"POST / HTTP/1.0rn");
fputs($fp,"Host: ping.feedburner.comrn");
fputs($fp,"User-Agent: Bean's Weblogs.com Updater (PHP Stylin')rn");
fputs($fp,"Content-Type: text/xmlrn");
fputs($fp,"Content-length: $lenrnrn");
fputs($fp,"weblogUpdates.ping$name$url");
$output="";
while(!feof($fp)) $output.=fgets($fp,4096);
fclose($fp);
}

$output = preg_replace("/.*/si","",$output);
$output = preg_replace("/.*/si","",$output);
$output = preg_replace("/.*/si","",$output);
return $output;
}
?>
 Quote

shinji

Anonymous
Oops. That last part should of looked like this. Thats what I get for not previewing the message first.

Anyways starting with the first real line (not including comments or blank lines), you can change ping.feedburner.com in both lines 5 and 13 to match. Just change the address part. Line 12 can be changed. The backslash may or may not be followed with RPC2. I know some sites might. They might have other folders to ping into. You will need to find out and change it accordingly. Line 6 can be changed or left alone. It isn't required at all.
 Quote

All times are EDT. The time is now 01:57 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content