Пример #1
0
 static function onConstruct($conf)
 {
     self::$host = $conf->host . '/' . $conf->org_name . '/' . $conf->app_name;
     self::$client_id = $conf->client_id;
     self::$client_secret = $conf->client_secret;
     //使用memcache缓存token
     $frontCache = new FrontData(["lifetime" => 86400]);
     self::$mCache = new BackMemCached($frontCache, ["servers" => [["host" => "127.0.0.1", "port" => "11211", "weight" => "1"]]]);
 }
Пример #2
0
 public function register()
 {
     $request = $this->getHeaderBody();
     $userModel = new User();
     //验证手机 模拟通过
     if (!$request->key) {
         sendMsg('KEY NOT FIND', 1);
     }
     $phone = $this->mCache->get($request->key);
     if (!$phone) {
         sendMsg('KEY ERROR', 1);
     }
     if ($userModel->issetPhone($phone['phone'])) {
         sendMsg('PHONE USED', 1);
     }
     //清理key
     $this->mCache->delete($request->key);
     $userModel = new User();
     $createData = ['phone' => $phone['phone'], 'registerTime' => new MongoDate(), 'registerIP' => $this->request->getClientAddress()];
     foreach ($request as $key => $val) {
         if (in_array($key, ['phone', 'password', 'userName', 'sex'])) {
             $createData[$key] = $val;
         }
         if ($key == 'password') {
             $createData[$key] = mkPwd($val);
         }
         //头像
         if ($key == 'headerimg' && file_exists(TEMP_PATH . '/' . $val)) {
             if (copy(TEMP_PATH . '/' . $val, HEADERIMG_PATH . '/' . $val)) {
                 $createData['headImg'] = $val;
             }
         }
     }
     $res = $userModel->createUser($createData);
     if ($res) {
         //注册EM账户密码
         EM::onConstruct($this->config->em_conf);
         $imUser = EM::createUser();
         if ($imUser) {
             $imUser['userId'] = $res;
             $userModel->create_imuser($imUser);
         }
         sendMsg("OK");
     } else {
         sendMsg('NOT CREATE', 1);
     }
 }
Пример #3
0
 public function onConstruct()
 {
     EM::onConstruct($this->config->em_conf);
 }