How does php implement the function of sending text messages? Is there any library? I wonder if there is any service for sending text messages for free. Please kindly advise. How does php implement the function of sending text messages? Is there any library? I wonder if there is any service for sending text messages for free. Please kindly advise.
Reply content:
How does php implement the function of sending text messages? Is there any library? I wonder if there is any service for sending text messages for free. Please kindly advise.
A picture shows the general principle:
The red request line is the focus of our attention. third-party service providers generally use HTTP to send text messages to APIs.
Go to the service provider's SMS official website to check the API. Generally, the php sms sdk is provided.
If not, you can write it by yourself. The following example
Make sure that curl support is enabled.
Or use file_get_contents directly.
'Bar'); $ data = http_build_query ($ data); $ opts = array ('http' => array ('method' => 'post ', 'header' => 'content-type: application/x-www-form-urlencodedrn '. "Content-Length :". strlen ($ data ). "rn", 'content' => $ data); $ context = stream_context_create ($ opts); $ html = file_get_contents ('https: // www.baidu.com ', false, $ context); echo $ html; // GET $ url = 'HTTP: // www.baidu.com/'{}html = file_get_contents ($ Url); echo $ html;?>
Http://www.yunpian.com
Send text messages. You need to pick up third-party text message providers. Generally, demos are provided.
Each text messaging platform is different.
This has nothing to do with the database. Services provided by third parties. You can simply call http.
Almost no free, we use Alibaba big fish, the speed is extremely fast...
The configuration is extremely simple .. You can send a get request ..
Disadvantage: relatively expensive ..
Http://www.alidayu.com/
For paid third-party services, you can use Baidu text message api
If I want to post the screw cap document, it will not seem a little low.
$ Ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, "http://sms-api.luosimao.com/v1/send.json"); curl_setopt ($ ch, CURLOPT_HTTP_VERSION, expiration); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, 30 ); curl_setopt ($ ch, expires, TRUE); curl_setopt ($ ch, CURLOPT_HEADER, FALSE); curl_setopt ($ ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt ($ ch, expires, 'api: key-b761c24f77fc5d77769d5a442ccacc10 '); curl_setopt ($ ch, CURLOPT_POST, TRUE); curl_setopt ($ ch, CURLOPT_POSTFIELDS, array ('mobile' => '2016', 'message' => 'verification code: 123456 [iron shell network] '); $ res = curl_exec ($ ch); curl_close ($ ch); // $ res = curl_error ($ ch ); var_dump ($ res );
Returned results:
{"error":0,"msg":"ok"}
Http://submail.cn/chs/documents/developer/BSx2b3 submail php sms sdk, hope to help you :)
Http://sms.mob.com/#/sms
No for free
Free of charge. There is usually a quota for your test. Has been using http://www.yuntongxun.com, all aspects are good, the implementation is also simple.
We use cloud news. This is OK.
We use android to write an APP for text messaging.