#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Free worldwide SMS sending script using Solinked API.
import sys
import requests
forge_user_agent = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'
script_url = 'http://solinked.com/solinked/sendsms.php'
forge_headers = {
'Origin' : 'http://solinked.com',
'Connection' : 'keep-alive',
'User-Agent' : forge_user_agent,
'Content-Type' : 'application/x-www-form-urlencoded',
'Referer' : 'http://solinked.com/',
}
def sendsms(destphone, smsbody):
resp = requests.get('http://solinked.com/')
forge_headers['Cookie'] = resp.headers['Cookie']
html = resp.text
numberfield_key_pattern = r"' id='no' class='no'"
checkfield1_key_pattern = r"' id='on' class='n0'"
checkfield2_key_pattern = r'" class="formsend"'
numberfield_end_pos = html.find(numberfield_key_pattern)
checkfield1_end_pos = html.find(checkfield1_key_pattern)
checkfield2_end_pos = html.find(checkfield2_key_pattern) - 41
checkfield2_val_end_pos = html.find(checkfield2_key_pattern)
numberfield = html[numberfield_end_pos-32:numberfield_end_pos]
checkfield1 = html[checkfield1_end_pos-32:checkfield1_end_pos]
checkfield2 = html[checkfield2_end_pos-32:checkfield2_end_pos]
checkfield2_val = html[checkfield2_val_end_pos-32:checkfield2_val_end_pos]
reqfields = {numberfield : destphone, checkfield1 : '', checkfield2 : checkfield2_val, 'mymessage' : smsbody}
print repr(reqfields)
resp = requests.post(script_url, reqfields , headers=forge_headers)
if __name__ == "__main__":
if len(sys.argv) < 3:
print "Usage: solinked [num in international format with 00 instead of +] [message]"
else:
sendsms(sys.argv[1], sys.argv[2])
print "Message sent"