Created
September 26, 2010 15:24
-
-
Save marcelcaraciolo/598018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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