Skip to content

Instantly share code, notes, and snippets.

@slpsys
Created February 16, 2012 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slpsys/1846888 to your computer and use it in GitHub Desktop.
Save slpsys/1846888 to your computer and use it in GitHub Desktop.
def _postToZendesk(self, text, originalMsg):
try:
url = 'http://xignite.zendesk.com/tickets/%s.xml' % (text)
body = self._getZendeskMessage(originalMsg)
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('Web Password', url,'username', 'password')
opener = urllib2.build_opener(auth_handler)
request = urllib2.Request(url, data=body)
request.add_header('Content-Type', 'application/xml')
request.get_method = lambda: 'PUT'
url = opener.open(request)
except:
print 'Could not post to Zendesk, please let the user know that the ticket has been updated manually.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment