def register_by_name_pwd(username, password, nickname = nil)
      token =    self.auth_token()

      result = HTTParty.post("#{@head_url}/users", 
          :body => { :username     => username, 
                     :password     => password, 
                     :nickname     => nickname
                   }.to_json,
          :headers => { 'Content-Type' => 'application/json', 'Authorization'=>"Bearer #{token}" } )
      if result.response.code.to_i == 200
        return [username, password] 
      else
        nil
      end
    end
def register_by_name_pwd(username, password, nickname = nil)
      token =    self.auth_token()

      result = HTTParty.post("#{@head_url}/users", 
          :body => { :username     => username, 
                     :password     => password, 
                     :nickname     => nickname
                   }.to_json,
          :headers => { 'Content-Type' => 'application/json', 'Authorization'=>"Bearer #{token}" } )
      if result.response.code.to_i == 200
        return [username, password] 
      else
        nil
      end
    end
注册用户到环信,使用外部的用户名和密码