Topic: Basic use of suds for ET
I have a bit of basic Python code for using ET with the "suds" Python library. Anyone else using suds for ET development?
import logging
from suds.client import Client
from suds.wsse import *
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
security = Security()
token = UsernameToken('yourusername', 'yourpassword')
security.tokens.append(token)
wsdl = 'https://webservice.exacttarget.com/etframework.wsdl'
client = Client(wsdl)
client.set_options(wsse=security)
# Show the version number
print client.service.VersionInfo(True)
# Show the list of methods that can be called
print client
# Create a new Email object that will be visible in ExactTarget
testemail = client.factory.create('Email')
testemail.Name = "TestingSuds"
testemail.Subject = "Testing the Suds Soap library for Python"
testemail.PartnerKey = "ExternalKey123"
testemail.HTMLBody = "This is an important test e-mail. <strong>Very</strong> important, in fact."
testoptions = client.factory.create('CreateOptions')
client.service.Create(testoptions, [testemail])Please note: I don't think that this is secure code. The username and password in this code example are sent as plain text. To use this for anything other than testing, you'll need to tunnel through HTTPS. See https://fedorahosted.org/suds/wiki/Docu ENTICATION and http://www.threepillarsoftware.com/soap_client_auth for more information.
Last edited by etdev (2009-12-18 17:39:55)