Text message platform PHP code plug‑php tutorial

Source: Internet
Author: User
The PHP code of the SMS platform is always available. There have been many opportunities to access the text messaging platform in recent times. it seems that the customer's text messaging platform was developed using PHP. the code is as follows :? PHP has a lot of opportunities to access the text messaging platform in the recent period. think about it as if the customer's text messaging platform was developed using PHP. the code is as follows:

$ Flag = 0;
// Data to be post
$ Argv = array (
'SN '=> 'sdk-BBX-010-XXXXX ',
'Pwd' => 'xxxxxx ',
'Mobile' => '134338xxxxx', // mobile phone number of the test
'Content' => 'Hello, test SMS'
);
// Construct the string to post
Foreach ($ argv as $ key => $ value ){
If ($ flag! = 0 ){
$ Params. = "&";
$ Flag = 1;
}
$ Params. = $ key. "="; $ params. = urlencode ($ value );
$ Flag = 1;
}
$ Length = strlen ($ params );
// Create a socket connection
$ Fp = fsockopen ("sdk2.entinfo.cn", 80, $ errno, $ errstr, 10) or exit ($ errstr. "--->". $ errno );
// Construct the post request header
$ Header = "POST/z_send.aspx HTTP/1.1 \ r \ n ";
$ Header. = "Host: sdk2.entinfo.cn \ r \ n ";
$ Header. = "Referer:/mobile/sendpost. php \ r \ n ";
$ Header. = "Content-Type: application/x-www-form-urlencoded \ r \ n ";
$ Header. = "Content-Length:". $ length. "\ r \ n ";
$ Header. = "Connection: Close \ r \ n ";
// Add the post string
$ Header. = $ params. "\ r \ n ";
// Send post data
Fputs ($ fp, $ header );
$ Inheader = 1;
While (! Feof ($ fp )){
$ Line = fgets ($ fp, 1024); // only the returned data on the page is displayed when the request packet header is removed.
If ($ inheader & ($ line = "\ n" | $ line = "\ r \ n ")){
$ Inheader = 0;
}
If ($ inheader = 0 ){
// Echo $ line;
}
}
If ($ line = 1)
{
Echo 'message sent successfully, please check the returned value '. $ line;
} Else
{
Echo 'message sending failed. Please check the returned values of related errors '. $ line;
}
Fclose ($ fp );

Why :? PHP...

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.