Httppost the XML file to an address. Recently, I made a small task to send group messages and MMS messages. The partner provides an interface. we only need to splice the content to be sent into an XML file, and then httppost to that address. Recently, I made a small task to send group messages and MMS messages. The partner provides an interface. we only need to splice the content to be sent into an XML file, and then send an http post to that address. Here the curl library is used, and the usage is simply recorded.
The following is a small program for sending text messages. First, you can obtain the number from the text of an uploaded phone number and then obtain the content and send it.
0) {echo 'problem: '; switch ($ _ FILES ['phone _ num'] ['error']) {// 1 indicates that the File size exceeds the limit in php configuration. case 1: echo 'file exceeded max in phi. ini! '; Break; // 2 indicates that the maximum limit is exceeded case 2: echo 'file exceeded max_file_size'; break; // 3 indicates partial Upload case 3: echo 'file only partially uploaded '; break; // 4 indicates that case 4: echo 'No file upload'; break;} exit;} // if the file type is not plain text, if ($ _ FILES ['phone _ num'] ['type']! = 'Text/plain ') {echo 'problem: file is not plain text'; exit;} // transfer file path, transfer failed, output error $ dir = dirname (_ file __). '/upload/'; $ filename = $ _ FILES ['phone _ num'] ['name']; $ savepath = "$ dir/$ filename "; if (is_uploaded_file ($ _ FILES ['phone _ num'] ['tmp _ name']) {$ state = move_uploaded_file ($ _ FILES ['phone _ num'] ['tmp _ name'], $ savepath); // if the upload is successful, preview if ($ state) {// echo "";}/** if (! Move_uploaded_file ($ _ FILES ['phone _ num'] ['tmp _ name'], $ savepath) {echo 'problem cocould not move file to destination directory'; exit ;} */} else {echo 'problem: possible file upload attack file: '; echo $ _ FILES ['phone _ num'] ['name']; exit ;} $ pn = file_get_contents ($ savepath); $ content = $ _ POST ['content']; $ xml_data ='
3100
Lwxkk
1234567
106581036177
'. $ Pn .'
'. $ Content .'
'; $ Url = 'http: // www.bkjia.com/service/tasksubmit'{//receiving xmladdress Authorization header = "Content-type: text/xml"; // Define content-type as xml $ ch = curl_init (); // initialize curlcurl_setopt ($ ch, CURLOPT_URL, $ url); // Set the link curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // Set whether to return information curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); // Set the HTTP header curl_setopt ($ ch, CURLOPT_POST, 1); // Set it to the POST method curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ xml_data ); // POST data $ respo AUC = curl_exec ($ ch); // receives the returned information if (curl_errno ($ ch) {// The error message print curl_error ($ ch) is displayed when an error occurs );} curl_close ($ ch); // Close the curl link echo $ response; // display the returned information?>
Sending a group of mms is a little troublesome. you need to name and package the text, images, mms. smil and other files as required, but the sending principle is the same.
310
Lwxk
123456
106581036177
'. $ Pn .'
'. $ Title .'
'. $ Encoded .'
'; $ Url = 'http: // www.bkjia.com/service/tasksubmit'{//receiving xmladdress Authorization header = "Content-type: text/xml"; // Define content-type as xml $ ch = curl_init (); // initialize curlcurl_setopt ($ ch, CURLOPT_URL, $ url); // Set the link curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // Set whether to return information curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); // Set the HTTP header curl_setopt ($ ch, CURLOPT_POST, 1); // Set it to the POST method curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ xml_data ); // POST data $ respo AUC = curl_exec ($ ch); // receives the returned information if (curl_errno ($ ch) {// The error message print curl_error ($ ch) is displayed when an error occurs );} curl_close ($ ch); // Close the curl link echo $ response; // display the returned information?>
In fact, it is very easy to splice the content into an XML string, compile the code according to the required base_64, and then post it to the address.
Bytes. The partner provides an interface. we only need to splice the content to be sent into an XML file, and then send an http post to that address ....