Complete SMS message forwarding with PHP server

Source: Internet
Author: User
Tags php server urlencode

I've been writing python for two days.

Active defense system has been missing a send SMS message notification function, so try to write a PHP to do the background module


   //Lian$link= Mysql_connect (sae_mysql_host_m.':'. Sae_mysql_port,sae_mysql_user,sae_mysql_pass);if($link) {mysql_select_db (sae_mysql_db,$link);$getid= mysql_query ("select Max (id_p) from--your_datatable--");$row= Mysql_fetch_array ($getid);$id=$row[0]+1;$content= Addslashes ($_post[' content ']);$token= Addslashes ($_post[' token ']);if($content)        {if($token=="--your_token--") {mysql_query ("INSERT into '--your_database--'. '--your_datatable--' (' id_p ', ' Content ') VALUES (' $id ', ' $content ')");$smsapi="--sms_gateway--";//SMS Gateway$user="--sms_account--";//SMS Platform account$pass="--sms_password--";//SMS Platform password$content=" Active Defense" Sir, I get some thing: ".$content;//SMS content to be sent$sendurl=$smsapi."sms?u=".$user."&p=".$pass."&m="."--your_phone--"."&c=". UrlEncode ($content);$result= File_get_contents ($sendurl) ; }Else{$msg="token wrong!".$content; mysql_query ("INSERT into '--your_database--'. '--your_datatable--' (' id_p ', ' Content ') VALUES (' $id ', ' $msg ')"); }} mysql_close ($link); }Echo"

Hello

";?>

Python writes the front-end very simple, because later is to integrate into the active defense API inside, did not add those fancy things.

# -*- coding: utf-8 -*-import urllib2import urllibdata = {}data['token''--YOUR_TOKEN--'data['content''--YOUR_MESSAGE--'"--PHP_ADDRESS--"post_data = urllib.urlencode(data)req = urllib2.urlopen(url, post_data)print ("Finish")

That's the way it is, it's going to be an exam next week, and the defense system has to be put down.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the use of PHP server to complete the SMS message forwarding, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.