A problem with python drupal services

Events happening in the community are now at Drupal community events on www.drupal.org.
dofbi's picture

Hi i try to run this code on Drupal 6.x but i get an error :
A fault occurred
Fault code: 1
Fault string: Wrong username or password.
can some body already try python to access with Drupal xmlrpc and to get authentificate

#

import xmlrpclib, time

Put the URL for your Service in here. See admin/build/services.

config = {
'url': 'http://twitter.connexionservice.com/services/xmlrpc',
'username': 'developer',
'password': 'password',
}
s = xmlrpclib.Server(config['url'], allow_none=True)
class node:
# You need to set uid and username appropriately for your site if you don't want
# everything to be posted by Anonymous.
def init(self, title, body, path, ntype='twitterpost', uid=3, username='dofbi'):
self.title = title
self.body = body
self.path = path
self.type = ntype
self.uid = uid
self.name = username
self.promote = False

try:
connection = s.system.connect()
session = s.user.login(connection['sessid'], config['username'], config['password'])
sessid = session['sessid']
# Here you could read in the content for each node from some other source and do
# n = node(title, body, path)
# but for now we'll just do:
n = node('A test node', 'This is an interesting page', 'interesting')
# and then save it into Drupal
s.node.save(sessid, n)
# where it should appear at /interesting.

except xmlrpclib.Fault, err:
print "A fault occurred"
print "Fault code: %d" % err.faultCode
print "Fault string: %s" % err.faultString

Comments

try my example for drupal

dgtlmoon code works for

josepvalls's picture

dgtlmoon code works for Drupal 6.x with Services 3.x

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: