在 auth_email_signup_user 函数的参数数组中检测到意外键(性别、出生日期)

Unexpected keys (gender, dob) detected in parameter array on auth_email_signup_user function

我正在尝试向 android 应用程序添加注册,该应用程序使用托管在 Moodle 站点的服务器的标准 Moodle 端点。所以在邮递员上,我使用函数“auth_email_signup_user”和字段:

firstname:Mteja
lastname:WaNambari
email:mteja@gmail.com
username:mteja
password:1234pass
gender:Male
dob:05/09/2000

但后来我不断收到邮递员的回复

{
    "exception": "invalid_parameter_exception",
    "errorcode": "invalidparameter",
    "message": "Invalid parameter value detected",
    "debuginfo": "Unexpected keys (gender, dob) detected in parameter array."
}

也许有人可以帮我解决这个问题

此函数的参数可在以下代码中找到: https://github.com/moodle/moodle/blob/master/auth/email/classes/external.php#L187

如果你在那里查看,你会发现预期的参数是:

  • 用户名
  • 密码
  • 名字
  • 姓氏
  • 电子邮件
  • 城市(可选 - VALUE_DEFAULT 部分表明了这一点)
  • 国家(可选)
  • recaptchachallengehash(可选)
  • 重新捕获响应(可选)
  • customprofilefields(可选 - 数组)
  • 重定向(可选)

我假设 'gender' 和 'dob' 是您为您的站点定义的自定义配置文件字段(因为我不认为这些是标准字段)。

如果这是正确的,那么您将需要发送如下所示的数据:

firstname:Mteja
lastname:WaNambari
email:mteja@gmail.com
username:mteja
password:1234pass
customfields[0][name]:gender
customfields[0][value]:Male
customfields[0][type]:text
customfields[1][name]:dob
customfields[1][value]:05/09/2000
customfields[1][type]:date

(恐怕我对 'type' 字段有点猜测 - 从代码来看它似乎是一个必填字段,但同时我看不到它是实际使用。日期格式可能还需要是 Unix 时间戳,而不是格式化日期 - 我现在没有 Moodle 安装在我面前以查看它是否有效。