Last active
December 29, 2016 14:54
-
-
Save ri-sh/f0e62ec20575f4c1d09a to your computer and use it in GitHub Desktop.
way2sms message
This file contains hidden or 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
#------------------------------------------------------------------------------- | |
# Name: Way2sms | |
# Purpose: send sms way2sms # | |
# Author: Rishabh Roy | |
# | |
# Created: 09/08/2015 | |
# Copyright: (c) Rishabh 2015 | |
# Licence: <GPL> | |
#------------------------------------------------------------------------------- | |
import urllib2 | |
import cookielib | |
from getpass import getpass | |
import sys | |
#login to way 2 sms .com replace your username with your mobile number on way2sms and password here | |
username= "" | |
passwd='' | |
def Way2sms(message,number): | |
message="+".join(message.split(' ')) | |
url= 'http://site21.way2sms.com/Login1.action' | |
data = 'username='+username+'&password='+passwd | |
cj =cookielib.CookieJar() | |
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | |
opener.addheaders=[('User-Agent',"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36")] | |
try: | |
usock = opener.open(url,data) | |
except IOError: | |
print "cannot connect " | |
sys.exit(1) | |
jession_id=str(cj).split('~')[1].split(' ')[0] | |
print jession_id | |
p= opener.open("http://site21.way2sms.com/ebrdg.action?id="+jession_id) | |
send_sms_url='http://site21.way2sms.com/smstoss.action' | |
send_sms_data= 'ssaction=ss&Token='+jession_id+'&mobile='+number+'&message='+message+'&msgLen='+str(140-len(message)) | |
opener.addheaders=[('Referer','http://site21.way2sms.com/sendSms?Token='+jession_id)] | |
#opener.addheaders=[('Host','site21.way2sms.com')] | |
try: | |
sms_sent_page = opener.open(send_sms_url,send_sms_data) | |
except IOError as e : | |
print e | |
p=opener.open('http://site21.way2sms.com/smscofirm.action?SentMessage='+message+'&Token='+jession_id+'&status=0') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment