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: & lt ;? PHP $ flag = 0; // the data to post $ argv = array (& amp; #39; sn & amp; #39 ;=& gt; & amp; #39; SDK-BBX-0... "> <LINKh
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, so I found some materials to learn about it. 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 );