如何在PHP API中为Parse

时间:2015-07-14 17:01:32

标签: php mongodb api curl parse-platform

我正在构建一个移动互动游戏,根据用户操作,他会被分配好坏点并获得通知等等。

我有一个PARSE集合,其中有四个字段(在其他字段中):

- GoodPoints
- EvilPoints
- PlayerID
- deviceToken

使用Parse API我想要一个只有在玩家“好”(goodPoints> evil Points)时才会发送通知的查询。我不确定如何使用PHP Parse API为此编写查询。

我目前有:

$pushPayload = json_encode(array(
    "where" => array(
        'playerId' => $playerId
        //here I need to add a condition which says goodPoints > evilPoints
     ),
     "data" => array("alert" => "You have turned good!")
));
//..followed by curl call to PARSE API URL..

上述查询和随后的cURL调用命中解析集合,找到播放器的设备并向他发送通知。但是,我想添加附加条件,以便仅在userID匹配且goodPoints>时查找记录。 evilPoints。

任何人都可以帮我弄明白怎么做吗?我认为查询是MongoDB风格,但我似乎无法做到正确。非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

我假设您正在使用:phusion/baseimage

https://www.parse.com/

如果是这样,那么我认为它会像:

def anti_vowel(text):
 letters = text.split() #make a list of all the letters in the string
 index = 0 #for del
 for x in letters:
     if x == "a" or x == "A" or x == "u" or x == "U" or x == "i" or x == "I" or x == "o" or x == "O" or x == "e" or x == "E":
         del letters[index]
     index += 1 #to make the if-clause work
 return "".join(letters) #turn the edited list into a string