[ 'class' => QueryParamAuth::className(), 'tokenParam' => "token",//access-token修改为token 'optional' => [//不需要认证方法名 array 'apply-offer','apply-design' ], ] ]); } /** * 申请报价 * @return array */ public function actionApplyOffer() { $post = Yii::$app->request->post(); if(empty($post['area_id'])) return Apireturn::sent(0,'请选择城市'); if(!Common::is_price($post['acreage'])) return Apireturn::sent(0,'请输入正确的面积'); if(empty($post['nickname'])) return Apireturn::sent(0,'请输入昵称'); if(!Common::is_tel($post['tel'])) return Apireturn::sent(0,'请输入正确的手机号'); $model = new Offer(); $model->area_id =$post['area_id']; $model->nickname = $post['nickname']; $model->tel = $post['tel']; $model->acreage = $post['acreage']; $model->layout = $post['shi']."室".$post['ting']."厅".$post['chu']."厨".$post['wei']."卫".$post['yang']."阳"; $model->c_time = time(); $model->status = Offer::STATUS_YES; if($model->save()){ $url = "http://to8tozb.to8to.com/zb/zb-index-get.php?callback=jsonpCallback&modeltype=8&ptag=1_1_1_846&square={$post['acreage']}&town=&shi={$post['shi']}&ting={$post['ting']}&wei={$post['wei']}&yangtai={$post['yang']}&chu={$post['chu']}&type=detail&dangci=jianzhuang&nowstep=1&autoPop=0&xgtqbj=1&rsadata=qdUE67XgTT7GUlRxb%252FAuxY0kIQwimOPyeimw7fZ77l8XwEXvH9IxQu2%252Fk4o0Kkn0vhYp2Q08%252FLKAH0KUFGMZhr8RLiIrUVqadPAkeiahyaRq1SLHK%%&rsastatus=1&"; $call = self::httpGets($url); $json = substr($call, 14, -1); $json = json_decode($json, true); if(!empty($json['demo'])) { $sms = new Sms(); $content = $model->layout.",您家装修预算约为".round($json['sgbz_price']/10000*2,1)."万元,因材料品牌及工程量不同,具体报价以量房实测为准。稍后装修管家将回电您,免费提供装修咨询服务。如非本人操作,请忽略。"; $result = $sms->SendMessage($model->tel,$content); } return Apireturn::sent(1,'申请成功!报价结果将发送到您的手机,请保持手机畅通'); } else{ return Apireturn::sent(0,'申请失败'); } } /** * 申请设计 */ public function actionApplyDesign() { $post = Yii::$app->request->post(); if(empty($post['nickname'])) return Apireturn::sent(0,'请输入昵称'); if(!Common::is_tel($post['tel'])) return Apireturn::sent(0,'请输入正确的手机号'); if(empty($post['area_id'])) return Apireturn::sent(0,'请选择城市'); $model = new Design(); $model->area_id =$post['area_id']; $model->nickname = $post['nickname']; $model->tel = $post['tel']; $model->c_time = time(); $model->status = Design::STATUS_YES; if($model->save()) return Apireturn::sent(1,'申请成功!客服将尽快与您取得联系,请保持手机畅通'); else return Apireturn::sent(0,'申请失败'); } /** * curl get 方式获取远程Url内容 * @param string $url Url http://xxxx.xx.xx * @param array $param 参数数组 * @param int $header 是否构造http头 * @param string $ref 伪造访问来路 * @param int $timeout 超时时间 秒 * @return mixed */ public function httpGets($url, $param = array(), $header = 1, $ref = 'http://www.baidu.com', $timeout = 3) { if ($param != null) { $query = http_build_query($param); $url = $url . '?' . $query; } $ch = curl_init(); // 跳过SSL证书验证 if (stripos($url, "https://") !== false) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);#设置缓冲时间 //构造http头 if ($header) { $ip = rand(10, 254) . '.' . rand(10, 254) . '.' . rand(10, 254) . '.' . rand(10, 254); $header = array("CLIENT-IP:{$ip}", 'X-FORWARDED-FOR:115.239.210.27',); curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//伪造ip curl_setopt($ch, CURLOPT_REFERER, $ref);//伪造访问来路 } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($ch); $status = curl_getinfo($ch); curl_close($ch); if (intval($status["http_code"]) == 200) { return $content; } else { return $status["http_code"]; } } }