Ping-o-matic is a service that calls (ping) server engines and popular services to notify them that you have new contents on your site. This will help you to get your pages indexed on that servers and so it should increase your traffic.
I don’t know if this system works, but it’s implemented also in any wordpress installation, so telling Ping-o-matic that you have new contents should be a good thing. :-)
I’ve searched the web for a function to do this with php, but I didn’t found it and I’ve decided to write it by myself.
Ping-o-matic as many other services works with XML-RPC protocol, the acronym means XML Remote Procedure Call. That is to say that you can call some servers and tell them to execute some action remotely. In this case we use XML-RPC protocol to call Ping-o-matic and tell him: “EHY! I’ve updated my site, here is the link!“.
Ping-o-matic take this link and send it to many other popular services.
The complex part, for me, was understing XML-RPC rules and build the correct headers to call the service. The call is made with fsockopen php function. Here is the function that will be added to the next version of Mini Bot Class.
/*
--------------------------------------------
$title contains the title of the page you're sending
$url is the url of the page
$debug true print out the debug and show xml call and answer
--------------------------------------------
the output is an array with two elements:
status: ok / ko
msg: the text response from pingomatic
--------------------------------------------
*/
function pingomatic($title,$url,$debug=false) {
$content='<?xml version="1.0"?>'.
'<methodCall>'.
' <methodName>weblogUpdates.ping</methodName>'.
' <params>'.
' <param>'.
' <value>'.$title.'</value>'.
' </param>'.
' <param>'.
' <value>'.$url.'</value>'.
' </param>'.
' </params>'.
'</methodCall>';
$headers="POST / HTTP/1.0\r\n".
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)\r\n".
"Host: rpc.pingomatic.com\r\n".
"Content-Type: text/xml\r\n".
"Content-length: ".strlen($content);
if ($debug) nl2br($headers);
$request=$headers."\r\n\r\n".$content;
$response = "";
$fs=fsockopen('rpc.pingomatic.com',80, $errno, $errstr);
if ($fs) {
fwrite ($fs, $request);
while (!feof($fs)) $response .= fgets($fs);
if ($debug) echo "<xmp>".$response."</xmp>";
fclose ($fs);
preg_match_all("/<(name|value|boolean|string)>(.*)<\/(name|value|boolean|string)>/U",$response,$ar, PREG_PATTERN_ORDER);
for($i=0;$i<count($ar[2]);$i++) $ar[2][$i]= strip_tags($ar[2][$i]);
return array('status'=> ( $ar[2][1]==1 ? 'ko' : 'ok' ), 'msg'=>$ar[2][3] );
} else {
if ($debug) echo "<xmp>".$errstr." (".$errno.")</xmp>";
return array('status'=>'ko', 'msg'=>$errstr." (".$errno.")");
}
}
Related posts:

March 27th, 2010 12:08 am
This function is working succesfull.
Thank you my brother.
July 4th, 2010 5:21 pm
Appreciate the script!
July 11th, 2010 11:06 pm
Implemented this script in my blog to ping with every new post.
It works like a charm !!
Thank you for sharing this code!
July 13th, 2010 10:10 pm
Made some small changes (pingomatic to feedburner) and now the script pings feedburner as well.
Guess it can be used for more services.
It’s a great script. I made a blogpost about this at http://blog.atgp.nl/index.php?id=73 . It’s in Dutch so you might gain some fame in the Netherlands :-)
Thanks again!
July 14th, 2010 10:11 pm
I’ve read your post with google translate, thanks!
August 16th, 2010 9:10 am
yeah! it works! I even had it converted using curl… :)
btw there’s a little question i had in mind about the return xml from pingomatic…
when the ping is successful, pingomatic replied with xml which contain “Pings being forwarded to 13 services!”…what I have no idea with is the 13 services.. what services exactly those 13 really are? I’ve been searching the internet about that but no luck..
Do you know what it is? or anyone know?
thanks & regards,
steven
September 4th, 2010 12:55 am
Hello!Thanks a lot for this amazing script.I just have some questions.. because I cannot make it run.Does this script work with any website?Could you please provide some install instructions because I don’t have too many knowledges about php.Where to add the title and the url?Thank you!!!
October 5th, 2010 10:32 am
It works fine for me, tried it with XML RPC for IceRocket and it’s working as well
December 17th, 2010 4:10 pm
Will it automatically publish content to pingomatic, Whenever a new post is published?
Or we have to run this script everytime.
December 22nd, 2010 4:46 pm
For me the best SEO script ever made :)
Who is green guy down?
January 7th, 2011 11:49 am
finally.. 2 years ago, i was searching some methods to ping pingomatic.com for my blog script, but i didn’t find it and i stop my own php blog project,, but now, there’s a hope to rebuild my script.. thanks dude… :D
February 7th, 2011 12:42 pm
Finally i get the solution, this is good script and works fine for me. Now i can tweet and ping both.
February 21st, 2011 11:19 am
I have implemented your script, how to make sure that this script is working well in my site ? thanks for the explanation
March 7th, 2011 12:28 am
nice script, very nice.
Thanks for sharing
March 17th, 2011 6:09 pm
Awesome script, cheers dude – saved me a lot of time and effort lol :) x
May 11th, 2011 10:13 pm
Thank you so much for this. Saved me a lot of coding time. Much appreciated.
June 10th, 2011 5:11 am
Do you know if this works with other ping sites ?
July 2nd, 2011 9:42 am
[...] [...]
July 3rd, 2011 3:30 pm
this is very helpful for me. Thank you.
July 4th, 2011 5:39 pm
thanks for sharing, but.. can you show me for demo use this script? thanks before
August 1st, 2011 3:17 pm
just a question, can u ping other services as well?
September 20th, 2011 3:41 pm
how can use the script?
only with linux or windws? thanks
November 10th, 2011 7:26 pm
Sorry mate,
Run your script but get error: Array ( [flerror] => [message] => Pings being forwarded to 11 services! )
I dont know success or failure :(
November 11th, 2011 9:55 am
That message it’s an ok messagge! :-)