system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# vi:ts=4:et
# $Id: test_xmlrpc.py,v 1.7 2003/04/21 18:46:11 mfx Exp $
## XML-RPC lib included in python2.2
import xmlrpclib
import pycurl
# Header fields passed in request
xmlrpc_header = [
"User-Agent: PycURL XML-RPC Test", "Content-Type: text/xml"
]
# XML-RPC request template
xmlrpc_template = """
<?xml version='1.0'?><methodCall><methodName>%s</methodName>%s</methodCall>
"""
# Engage
c = pycurl.Curl()
c.setopt(c.URL, 'http://betty.userland.com/RPC2')
c.setopt(c.POST, 1)
c.setopt(c.HTTPHEADER, xmlrpc_header)
c.setopt(c.POSTFIELDS, xmlrpc_template % ("examples.getStateName", xmlrpclib.dumps((5,))))
print 'Response from http://betty.userland.com/'
c.perform()
c.close()