Advertisement
Guest User

Untitled

a guest
Apr 6th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. class SendingHandler(urllib2.HTTPHandler):
  2.     def http_response(self, req, response):
  3.         return response
  4.  
  5. ...
  6. ...
  7.  
  8.  
  9.         # send
  10.         msg = urllib.quote_plus(msg_body.encode('utf-8'))
  11.         url = "http://%s?secret=%s&action=sendSms&cid=%s&to=%s&msg=%s&handler=%s&arg1=%s&arg2=%s" % (config.apiServer, config.apiSecret, cid, to, msg, handler, arg1, arg2)
  12.  
  13.         # ready to send
  14.         logstr = "OK, We're ready to send."
  15.         logAppend(logstr)
  16.  
  17.         # threading
  18.         handler = urllib2.build_opener(SendingHandler())
  19.         thread = threading.Thread(target=handler.open, args=(url,))
  20.  
  21.         # start
  22.         logstr = "Starting thread..."
  23.         logAppend(logstr)
  24.  
  25.         thread.start()
  26.         thread.join()
  27.  
  28.  
  29.         logstr = "Success"
  30.         logAppend(logstr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement