在auth_email_signup_user函数的参数数组中检测到意外的键性别,dob

问题描述

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

firstname:Mteja
lastname:WaNambari
email:[email protected]
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(可选)
  • recaptcharesponse(可选)
  • customprofilefields(可选-数组)
  • 重定向(可选)

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

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

firstname:Mteja
lastname:WaNambari
email:[email protected]
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来查看它是否可以正常工作。)