Skip to content

Instantly share code, notes, and snippets.

@marcelcaraciolo
Created September 26, 2010 15:24
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 marcelcaraciolo/598018 to your computer and use it in GitHub Desktop.
Save marcelcaraciolo/598018 to your computer and use it in GitHub Desktop.
from twitterauth.models import User
import base64
import httplib
import urllib
def send_msg(userkey,tp):
url = 'www.imified.com'
form_fields = {
"botkey": "CODE", # Your bot key goes here.
"apimethod": "send", # the API method to call.
"userkey": str(userkey), # User Key to lookup with getuser.
"msg": tp,
'network' : 'Jabber'
}
# Build the Basic Authentication string. Don't forget the [:-1] at the end!
base64string = base64.encodestring('%s:%s' % ('email', 'senha'))[:-1]
authString = 'Basic %s' % base64string
# Build the request post data.
form_data = urllib.urlencode(form_fields)
# Make the call to the service using httplib command.
con = httplib.HTTPSConnection(url)
con.request('POST','/api/bot', form_data,{'AUTHORIZATION': authString})
response = con.getresponse()
if response.status == 200:
return HttpResponse(tp)
else:
return HttpResponse(response.reason)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment