【问题标题】:Cant access PFUsers from Parse无法从 Parse 访问 PFUser
【发布时间】:2015-12-10 05:34:05
【问题描述】:

我是解析和 ios 开发的新手。 我想使用 Parse 对 IOS 应用程序进行用户管理。在文档 (https://parse.com/docs/ios/guide#users-signing-up) 的帮助下,我能够注册一些示例用户,并且我在 Parse 应用程序中有以下内容。

然后我想通过以下文档帮助检索所有用户(或查询特定用户)。

var query = PFUser.query()
query.whereKey("gender", equalTo:"female")
var girls = query.findObjects()

预计我会收到一个大小为 3 的数组,但令人惊讶的是没有收到。

后来我发现我可以使用 Parse 的 API 控制台功能并尝试使用它来接收 PFUser 对象。我收到的结果为零。

后来我尝试使用示例表,我成功地将对象添加、检索到表中。

不确定我是否需要任何特别的东西才能使用PFUser

【问题讨论】:

  • 您能分享您的 pfuser 表架构,以便我可以在您的用户表中获得性别键的线索吗?

标签: ios parse-platform pfuser


【解决方案1】:

我已经使用 API 控制台 进行了测试,并且它在我这边工作。我在 User 表中有一项性别 = 男性。

我触发了以下 curl 查询以重试所有用户

curl -X GET \
  -H "X-Parse-Application-Id: <#your-application-key>" \
  -H "X-Parse-REST-API-Key: <#your-rest-api-key>" \
  -G \
  https://api.parse.com/1/users

上述查询的结果是:

  {"results":[{"gender":"male","createdAt":"2015-12-10T06:00:40.368Z","email":"sam07it22@gmail.com","objectId":"1KbxpYgeUb","updatedAt":"2015-12-10T06:01:32.885Z","username":"sam07it22@gmail.com"}]}

现在,我将在上述查询中添加 Condition 以获取性别 = 女性的记录。根据数据预期结果应该有零记录

对于性别 = 女性

curl -X GET \
  -H "X-Parse-Application-Id: <#your-application-key>" \
  -H "X-Parse-REST-API-Key: <#your-rest-api-key>" \
  -G \
  --data-urlencode 'where={"gender":"female"}' \
  https://api.parse.com/1/users

输出:

{"results":[]}

对于性别 = 男性

 curl -X GET \
      -H "X-Parse-Application-Id: <#your-application-key>" \
      -H "X-Parse-REST-API-Key: <#your-rest-api-key>" \
      -G \
      --data-urlencode 'where={"gender":"male"}' \
      https://api.parse.com/1/users

输出:

{"results":[{"gender":"male","createdAt":"2015-12-10T06:00:40.368Z","email":"sam07it22@gmail.com","objectId":"1KbxpYgeUb","updatedAt":"2015-12-10T06:01:32.885Z","username":"sam07it22@gmail.com"}]}

注意: 不要忘记替换您的 API KEYREST API KEY

【讨论】:

    【解决方案2】:

    ACL 权限成功了。 ACL 权限必须是“公共读取”才能访问。这是解析中有关 ACL 的更多信息https://parse.com/docs/ios/guide#security-object-level-access-control

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 2016-12-24
      • 1970-01-01
      相关资源
      最近更新 更多