Fetion PHP Class (Scatter) solution by SMS

Source: Internet
Author: User
Tags md5 encryption
Fetion text message sent by PHP class (scatter)
Fetion Send API Online There are many, but not much is my own satisfaction. Many websites provide web-based API calls to users, but as a user, I still have no end in mind. I always worry that my password will be recorded by some people, always want to write a PHP version of their own fetion send the program.
Because I do not have any reverse basis, while the fetion version changes different. It has been 3 years since Nathan published the Fetion protocol analysis on Baidu, and the Fetion 2006 version was analyzed at the time. This middle change too much, also make me in writing PHP version fetion send program is a lot of detours.
I have read superli_198 's "Let PHP program use Fetion (fetion) to send free text messages", but the version used by the communication method has not been fetion support, and superli_198 did not make new updates. I've also downloaded C.young[@]xicabin.com's openfetion, but there are obvious bugs in this version, and it's not working right now. Helpless can only bite the bullet to modify a C # version of the Fetion sender program.
During the porting of the C # version of Fetion to PHP, I encountered a problem related to MD5 encryption for many days. Finally, with the help of CSDN forum Yctin, the problem can be solved. Thank you very much yctin. The following is my completed PHP version of the fetion SMS send class, as of February 17, 2010 4 o'clock in the afternoon the program has been working properly. Technically there is no difficulty, send here and everyone to communicate.

PHP Code
  
  
  
   
  
  
   
  
  
   
  
  
   
  
  
   
  
  
   
  
  
   
  
  
   
  ";        /** * Use the mobile phone number and password to obtain the corresponding Fetion number information **/private $REQUEST _ssi_sign = "mobileno=%s&pwd=%s"; /** * Register with fetion number to SIPC server, get temporary variable NONCE and ssic value **/private $REQUEST _sipc_sign_nonce = "R%s sip-c/2.0\r\nf:%s\r    \ni:1\r\nq:1 r\r\nl:%d\r\n\r\n%s "; Private $REQUEST _sipc_sign_nonce_body = " 
  
   
  
  
   
  
  
   
  
  
   
    
 

   
  ";  /** * Login with fetion number and encrypted password fetion SIPC server **/private $REQUEST _sipc_login = "R%s sip-c/2.0\r\nf:%s\r\ni:1\r\nq:    2 r\r\na:digest response=\ "%s\", cnonce=\ "%s\" \R\NL:%d\r\n\r\n%s "; Private $REQUEST _sipc_login_body = "
  
   
  
  
   
  
  
   
  
  
   
    
 

   
  "; Private $REQUEST _sipc_sendsms = "M%s sip-c/2.0\r\nf:%s\r\ni:2\r\nq:1 m\r\nt:tel:%s\r\nn:sendsms\r\nl:%d\r\n        \r\n%s ";        Private $REQUEST _sipc_logout = "R%s sip-c/2.0\r\nf:%s\r\ni:1 \r\nq:3 r\r\nx:0\r\n\r\n"; /** [email protected] $sender SMS Sender phone number [email protected] $passwd SMS sender password [email protected] $rec Eiver SMS Receiver mobile number [email protected] $msg SMS content **/Public function __construct ($sender, $passwd, $receiver, $m        SG) {$this->mobile_no = $sender;        $this->fetion_pwd = $passwd;        $this->sms_receiver = $receiver;        $this->sms_text = $msg; $this->cookie_file = $this->mobile_no.        $this->cookie_file;                File_put_contents ($this->cookie_file, "); $this->fetiongetconfig (); Get login information from navigation website 443 Port $this->fetionsocektinit (); Initialize the 8080-port socket connection to SIPC $this->fetiongetsipcnonce (); Register the flight signal with the server to get the key variable value if ($this->fetionlogin ()) {//Send login Authentication command $this->fetionsendsms ();//Send SMS command $this->fetionlogo        UT (); }}/** * Get configuration information from the navigation address **/private Function fetiongetconfig () {$this->request_con        FIG = sprintf ($this->request_config, $this->mobile_no);        $this->curl = Curl_init ();        curl_setopt ($this->curl, Curlopt_url, $this->url_nav);        curl_setopt ($this->curl, Curlopt_ssl_verifyhost, false);        curl_setopt ($this->curl, Curlopt_ssl_verifypeer, false);        curl_setopt ($this->curl, Curlopt_cookiejar, $this->cookie_file);        curl_setopt ($this->curl, Curlopt_returntransfer, 1);        curl_setopt ($this->curl, curlopt_post, 1);        curl_setopt ($this->curl, Curlopt_postfields, $this->request_config); curl_setopt ($this->curl, Curlopt_proxy, $this->proxy_http); Set Proxy server $xml _config = curl_exec ($this,Curl);        The following is the XML information returned from the navigation page file_put_contents ("Test3.xml", $xml _config);        $xmlDom = new DOMDocument ();        $xmlDom->loadxml ($xml _config);        $fetion _server = $xmlDom->getelementsbytagname (' servers ');        $fetion _server->item (0)->getelementsbytagname (' Sipc-proxy ')->item (0)->nodevalue; $this->ssi_proxy_sign_in = $fetion _server->item (0)->getelementsbytagname (' ssi-app-sign-in ')->item (0)        ->nodevalue; $this->ssi_proxy_sigh_out = $fetion _server->item (0)->getelementsbytagname (' Ssi-app-sign-out ')->item (        0)->nodevalue;                $this->ssi_proxy_sign_in;        The following get the mobile phone number corresponding to the flight signal sprintf ($this->request_ssi_sign, $this->mobile_no, $this->fetion_pwd);        curl_setopt ($this->curl, Curlopt_url, $this->ssi_proxy_sign_in); curl_setopt ($this->curl, Curlopt_postfields, sprintf ($this->request_ssi_sign, $this->mobile_no, $this-        >FETION_PWD)); $ResUlt = curl_exec ($this->curl);        Curl_close ($this->curl);        File_put_contents ("Test4.xml", $Result);        $xmlDom->loadxml ($Result);        $uri = $xmlDom->getelementsbytagname ("user")->item (0)->getattribute ("uri"); "sip:[email protected];p =5914" if (Preg_match ('/^sip: (\d+) @ (\s+);.            *$/', $uri, $matches)) {$this->fetion_no = $matches [1];        $this->domain_fetion = $matches [2];  }}/** * Initialize fetion communication socket **/Private Function Fetionsocektinit () {$this->socket =        Socket_create (Af_inet, Sock_stream, sol_tcp); List ($ip _fetion, $port _fetion) = Split (': ', $this->sipc_proxy);    "221.176.31.4:8080" Socket_connect ($this->socket, $ip _fetion, $port _fetion); }/** * Register fetion number and get temporary variable nonce and ssic **/private Function fetiongetsipcnonce () {$REQUEST _sipc_sign_nonc        E = sprintf ($this->request_sipc_sign_nonce, $this->domain_fetion,                                   $this->fetion_no, strlen ($this->request_sipc_sign_nonce_body),        $this->request_sipc_sign_nonce_body);        $sock _data = Socket_write ($this->socket, $REQUEST _sipc_sign_nonce);        $buf = "; if (false = = ($buf = Socket_read ($this->socket, +))) {echo "line:". __line__. "Socket_read () failed; Reason: ". Socket_strerror (Socket_last_error ($this->socket)).        "\ n";        } $regex _ssic = '/.*nonce=\ ' (\\w+) \ ". */s";        if (!preg_match ($regex _ssic, $buf, $matches)) {echo "fetion error:no nonce found in socket\n";        } $this->nonce = Strtoupper (Trim ($matches [1]);        $regex _ssic = '/ssic\s+ (. *)/s ';  if (!preg_match ($regex _ssic, file_get_contents ($this->cookie_file), $matches)) {echo "Fetion Error:no Ssic        Found in cookie\n ";    } $this->ssic = Trim ($matches [1]); }
  • 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.