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 website!