Wednesday, February 22, 2017

Send free SMS Text Messages with Python


Short Message Service (SMS) text messages are ubiquitous for communication all over the world. It is easy to send SMS text messages from a Python application using a web application programming interface (API). Let's take a look at the tools we need to quickly add SMS capability to our Python apps.

Tools We Need

This guide works with both Python 2 and 3, so make sure you have one of those two versions installed.
run the following code in Python 2 or 3 script




Download the above code from below link

    import urllib2
import cookielib
from getpass import getpass
import sys
import os
from stat import *

def sendNotification(message, number):
    #message = "HII HELLO"
    #number = "9603592104"
    username = "put your way3sms username"
    passwd = "put your way3sms paswword"

    message = "+".join(message.split(' '))

    #logging into the sms site
    url ='http://site24.way2sms.com/Login1.action?'
    data = 'username='+username+'&password='+passwd+'&Submit=Sign+in'

    #For cookies

    cj= cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

    #Adding header details
    opener.addheaders=[('User-Agent','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120')]
    try:
        usock =opener.open(url, data)
    except IOError:
        print "error"
        #return()

    jession_id =str(cj).split('~')[1].split(' ')[0]
    send_sms_url = 'http://site24.way2sms.com/smstoss.action?'
    send_sms_data = 'ssaction=ss&Token='+jession_id+'&mobile='+number+'&message='+message+'&msgLen=136'
    opener.addheaders=[('Referer', 'http://site25.way2sms.com/sendSMS?Token='+jession_id)]
    try:
        sms_sent_page = opener.open(send_sms_url,send_sms_data)
    except IOError:
        print "error"
        #return()

    print "success" 
    #return ()

sendNotification('HI HELLO','put receiver mombile number')



Restaurant-android-application




The Restaurant App is a mobile reservation system that used for managing reservation and restaurant menu. Admin can manage reservation, restaurant menu and other configurations such as tax and currency code from admin panel on the web and users will be able to see the menu from mobile app and make a reservation. Run under Android platform which is the number one popular mobile operating system right now. 
Getting Started Before doing installation, you need to do the following things: 
1. Have a web hosting to store admin panel files and SQL database. Because this documentation using cpanel, a web hosting with cpanel is recommended. 
2. Install tools that requires for developing Android app such as Java Development Kit, Eclipse, Android SDK and ADT plugin. 
For updated tutorial about how to install them please see on Android Developer website here. Once you do all things above, you can go to the next step. 
Installing Admin Panel To install admin panel, login to your hosting via cpanel, it usually yourwebsite.com/cpanel. Select File Manager in Files section. It will bring you to File Manager page. 
On that page create new folder inside public_html, name it as you like, for example Restaurant. Then upload Admin_Panel.zip package into that folder and select Extract to extract that package. 
Once it done, back to cpanel, go to Databases section and select MySQL® Databases. In MySQL Databases create new database, database name is up to you. 
Add username and password to this database Go back to cpanel, select PhpMyAdmin in Databases section. You will go to PhpMyAdmin page, on that page select database that you have just created on the left side and click Import. 
Upload db_restaurant.sql by Choose File button and click Go. This will add some tables into database which are required by admin panel and android app. 
Back to File Manager and find variables.php in public_html/YOUR_FOLDER/variables. Open that file using Code Editor, this file contain some configurations such as database configuration, in this configuration you need to fill database host name, username, password, and database name your hosting configuration. Other configurations are access key, google play url, and contact email. If you change the access key value, you need to also change access key value on android app similar with this access key value
 <?php 
// database configuration 
$host ="db_host_name"; 
$user ="db_username"; 
$pass ="db_pasword"; 
$database = "database_name";
 $connect = new mysqli($host, $user, $pass,$database) or die("Error : ".mysql_error()); 
// access key to access API 
$access_key = "12345"; 
// email configuration $admin_email = "contact@website.com"; 
$email_subject = "The Restaurant App: Information Email"; 
$change_message = "You have change your admin info such as email and or password."; $reset_message = "Your new password is "; ... ?> 
Next, open close_database.php and connect_database.php located in includes directory using Code Editor. And find the following code,
include($_SERVER['DOCUMENT_ROOT'].'/YOUR_FOLDER/variables/variables.php');
change YOUR_FOLDER with folder name you have just created inside public_html. For example, if your folder name is Restaurant. Then the code above will look like this,
include($_SERVER['DOCUMENT_ROOT'].'/Restaurant/variables/variables.php');
Now you can go to admin page through YourWebsite.com/YOUR_FOLDER. 
Default username and password is admin. You can start creating category menu and new menu, set tax and currency code, and also change admin username, password and email. 
Importing Android Project To import The Restaurant App project firstly you need to extract the TheRestaurantApp.zip. 
Then, run Eclipse IDE, and select File > Import.... On Import window select Android > Existing Android Code Into Workspace then click Next. Find The Restaurant App project by clicking Browse... button then click Finish.
Thank you and enjoy....

Send free SMS Text Messages with Python

Short Message Service (SMS) text messages are ubiquitous for communication all over the world. It is easy to send SMS text messages fro...

Data Science

WEB Development