Use PHP to send text messages when goods are sold _ php instance

Source: Internet
Author: User
This article mainly introduces the function of sending text messages when goods are sold based on PHP. The code is simple and easy to understand. If you need it, you can refer to a project recently, where you need it, we are required to implement this function: send text messages when goods are sold. The core code below will be provided for you to learn later.

Html code omitted .....

Model Code omitted .....

The core code is as follows:

/** ----------------------------------------------- * Modify the public * Author: lzp Time: -- * required */public function changeStateAction () {$ id = $ _ REQUEST ['id']; $ result = $ this-> changeConfirmState ($ id); if ($ result) {$ this-> success ("modified successfully ");} else {$ this-> error ("failed to modify") ;}} private function changeConfirmState ($ id) {$ reg = $ this-> priceModel-> selectPrice (['id' => ['eq', $ Id]); $ rel = $ this-> demandModel-> selectDemand (['id' => ['eq ', $ reg [] ['demand _ id']); $ demand_id = $ reg [] ['demand _ id']; $ reg ['demand'] = $ this-> priceModel-> selectPrice (['demand _ id' => ['eq ', $ demand_id]); foreach ($ reg ['demand'] as $ key => $ value) {if ($ value ['phone'] = $ reg [] ['phone']) {unset ($ reg ['demand'] [$ key]);} else {$ new [] = $ value ['phone'] ;}} $ new = [''=> '*********']; if (time ()-strtotime ($ rel [] ['crea Te_time '])>) {echo "script alert ('timeout! '); History. back (); script "; die;} else if (strtotime ($ rel [] ['finish _ time'])>) {echo "script" alert ('closed! '); History. back (); script "; die;} else {$ data_demand = ['is _ available '=>, 'finish _ time' => date ("Y-m-d H: I: s")]; $ result ['price'] = $ this-> priceModel-> savePrice (['id' => ['eq ', $ id], ['state' =>]); $ result ['demon'] = $ this-> demandModel-> saveDemand (['id' => ['eq ', $ reg [] ['demand _ id'], $ data_demand); $ mobile = implode (",", $ new); $ content = "this requirement has been closed, come back next time! "; SmsApp ($ mobile, $ content); // send a text message return $ result ;}}

The above code is the core code provided by the editor. The code is still simple, so I didn't write too many comments for you. If you encounter any problems during the reference process, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the script home website!

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.