Home > Backend Development > PHP Tutorial > Based on PHP, the function of sending SMS when a product is completed is implemented. PHP SMS verification code platform. PHP SMS verification code software. PHP SMS verification code pass.

Based on PHP, the function of sending SMS when a product is completed is implemented. PHP SMS verification code platform. PHP SMS verification code software. PHP SMS verification code pass.

WBOY
Release: 2016-07-29 08:49:38
Original
1421 people have browsed it

I recently worked on a project, and there was a demand for us to implement this function: sending text messages when goods are sold. The editor posted the core code below for everyone to learn in the future.

html code omitted...

Model code omitted...

The core code is as follows:

  /*
* -------------------------------------------------
* 修改状态 public 
* Author: lzp Time:--
* -------------------------------------------------
*/
public function changeStateAction() {
$id = $_REQUEST['id'];
$result = $this->changeConfirmState($id);
if ($result) {
$this->success("修改成功");
} else {
$this->error("修改失败");
}
}
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[]['create_time']))> ){
echo "<script>alert('已超时!');history.back();</script>";
die;
}else if(strtotime($rel[]['finish_time'])>){
echo "<script>alert('已成交!');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['Demadn'] = $this->demandModel->saveDemand(['id'=>['eq',$reg[]['demand_id']]] , $data_demand);
$mobile = implode(",", $new);
$content = "此条需求已成交,下次再来哟!";
smsApp($mobile,$content); //发短信
return $result;
}
} 
Copy after login

The above code is the core code posted by the editor. The code is also It’s pretty simple, so I didn’t write too many comments for you. If you encounter any problems during the reference process, you are welcome to leave me a message. The editor will reply to you in time. Thank you very much for your support of this website!

The above has introduced the function of sending text messages when goods are sold based on PHP, including sending text messages and PHP content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template