通过curl php过滤firebase json数据

时间:2015-12-19 07:19:00

标签: json rest curl firebase

如何通过电子邮件ID" subu@gmail.com"?

搜索数据

firebase数据

{
    "-K5swDCvGh-fWBC3rvzz": {
        "email": "subu@gmail.com",
        "facebook_id": "123456789",
        "password": "111",
        "source": "facebook",
        "username": "subu"
    },
    "-K5sxFSS4NC8tRRCtN-t": {
        "email": "subu_google@gmail.com",
        "google_id": "987456321",
        "password": "111",
        "source": "google",
        "username": "subu_google"
    }
}

我的数据卷曲是

https://subu.firebaseio.com/users.json

我的firebase规则如下所示

{
    "rules": {
        "users": {
          ".indexOn": "email"
        },
        ".read": true,
        ".write": true
    }
}

1 个答案:

答案 0 :(得分:2)

使用orderBy查询字符串参数

curl https://subu.firebaseio.com/users.json?orderBy="email"

如果您需要进一步限制,可以使用startAtendAtequalTo

下面的查询通过电子邮件检索用户:

https://subu.firebaseio.com/users.json?orderBy="email"&equalTo="subu@gmail.com"

Read the section on Filtering Data in the Firebase docs for more information.