/** * 发送短信操作 * @param $user * @param $password * @param $mobiles * @param $message * @param $sign * @param $sendTime * @return bool */ private function sendSms($user, $password, $mobiles, $message, $sign, $sendTime) { $datas = array('name' => $user, 'pwd' => $password, 'mobile' => $mobiles, 'content' => $message, 'sign' => $sign, 'type' => 'pt', 'stime' => $sendTime); $httpClient = new HttpClient(); $result = $httpClient->post(self::$gateway, $datas); $this->result = $result; return $result[0] === '0'; }
/** * 发送短信操作 * @param $user * @param $password * @param $mobiles * @param $message * @param $sign * @param $sendTime * @return bool */ private function sendSms($user, $password, $mobiles, $message) { $datas = array('method' => 'Submit', 'account' => $user, 'password' => $password, 'mobile' => $mobiles, 'content' => $message); $httpClient = new HttpClient(); $result = $httpClient->get(self::$gateway, $datas); //解析xml文档 $xml = simplexml_load_string($result); $this->result = $xml->msg; //__print($xml); return $xml->code == '2'; }
/** * 第三方帐号微博登录返回的信息补全页面 * @param HttpRequest $request */ public function wbLogin(HttpRequest $request) { $code = $request->getParameter("code"); if (!empty($code)) { //$url = "https://api.weibo.com/oauth2/access_token"; $url = "https://api.weibo.com/oauth2/access_token?client_id=1725858045&client_secret=9ebb3937eefbb4cdeaf446a31e21b979&grant_type=authorization_code&redirect_uri=http://www.tuonews.com/wbLogin.php&code=" . $code; $httpWb = new HttpClient(); $tokens = $httpWb->post($url); $tokenTmp = json_decode($tokens, true); $token = $tokenTmp["access_token"]; //获取用户uid $url_uid = "https://api.weibo.com/oauth2/get_token_info"; $uidds = $httpWb->post($url_uid, array("access_token" => $token)); $uidtmp = json_decode($uidds, true); $uid = $uidtmp["uid"]; //获取用户信息 $url_user = "******" . $token . "&uid=" . $uid; $usertmp = file_get_contents($url_user); $userInfo = json_decode($usertmp, true); //如果openid在数据库中存在,则说明已经用这个账号注册过,直接跳转到登陆页面即可 $userService = Beans::get('user.user.service'); $openInfo = $userService->getItem("wb_openid = '{$userInfo["id"]}'", "*"); if (!empty($openInfo)) { //登录成功,清空登录失败的记录 if ($openInfo['ischeck'] == 2) { AjaxResult::ajaxResult('error', '您的帐号被封号,请联系管理员!'); } $userService->setLoginUser($openInfo); $this->location(url('/user_ucenter_profile')); } $this->assign("wbsign", true); $this->assign("userwbInfo", $userInfo); $this->setView("login_other"); } else { echo "授权出错,请重新授权"; } }