1

I'm trying to ping Pingomatic using python.

I've written this:

import xmlrpclib

print "START"

s = xmlrpclib.Server('http://rpc.pingomatic.com')
reply = s.weblogUpdates.ping('Test','http://www.testblog.com')

print "END"

But when I run, i get:

>>> 
START

Traceback (most recent call last):
  File "C:/xxxxxxxxxxxxxxxxxx/pingtest1.py", line 6, in <module>
    reply = j.weblogUpdates.ping('Test','http://www.testblog.com')
  File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27\lib\xmlrpclib.py", line 1570, in __request
    verbose=self.__verbose
  File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "C:\Python27\lib\xmlrpclib.py", line 1462, in parse_response
    p.feed(data)
  File "C:\Python27\lib\xmlrpclib.py", line 557, in feed
    self._parser.Parse(data, 0)
ExpatError: syntax error: line 1, column 0
>>> 

How can I fix this?

Thank you.

Gabriel Bianconi
  • 1,179
  • 3
  • 19
  • 37
  • Maybe `s = xmlrpclib.Server('http://rpc.weblogs.com/RPC2')`? – khachik Dec 13 '10 at 17:36
  • @khachik it works with weblogs, but it doesn't with pingomatic – Gabriel Bianconi Dec 13 '10 at 18:10
  • `ExpatError: syntax error: line 1, column 0` means that it didn't get an XML response (or any response). You might want to check pingomatic's API. – khachik Dec 13 '10 at 18:16
  • @khachik In PHP+Kohana, it worked fine (I'm trying to port to python). My code is: $content= xmlrpc_encode_request('weblogUpdates.ping', array($title,$url)); $header = array( 'Content-Type: text/xml', 'Content-Length: '.strlen($content), '\r\n' ); $result = Remote::get($target, array( CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $content, CURLOPT_HTTPHEADER => $header )); return xmlrpc_decode($result); – Gabriel Bianconi Dec 13 '10 at 18:31
  • Did you ever solve this issue? If so, it would be great if you could post the solution here, as I'm running into the exact same problem. Thanks! – Kyle Fox Aug 07 '11 at 18:43

1 Answers1

1

It turns out this was an issue with Pingomatic's response format. I tried pinging Weblogs.com, and it worked fine.

I emailed Automattic to let them know, and they've since fixed the issue -- everything should be working!

Kyle Fox
  • 3,133
  • 4
  • 23
  • 26