使用Where子句PHP获取解析服务器的api

使用Where子句PHP获取解析服务器的api,php,rest,curl,parse-server,Php,Rest,Curl,Parse Server,我使用以下代码使用PHP向Parse server的REST API发出GET语句: $query = json_encode( array( 'where' => array( 'userid' => "8728792347239" ) )); echo $query; $ch = curl_init('https://*hidden*.herokuapp.com/parse/classes/computers?'.$query); curl_setopt( $ch, C

我使用以下代码使用PHP向Parse server的REST API发出GET语句:

$query = json_encode(
array(
    'where' => array( 'userid' => "8728792347239" )
));
echo $query;
$ch = curl_init('https://*hidden*.herokuapp.com/parse/classes/computers?'.$query);
curl_setopt(
$ch, 
CURLOPT_HTTPHEADER,
array(
    'X-Parse-Application-Id: *hidden*',
    'X-Parse-REST-API-Key: *hidden*',
    'Content-Type: application/json'
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
print_r($response);
但是,我得到以下错误:

{"code":102,"error":"Invalid parameter for query: {\"where\":{\"userid\":\"8728792347239\"}}"}

我做错了什么?

在没有阅读文档的情况下,我打赌它应该是url编码的,而不是json编码的,或者数据应该在帖子正文中,而不是url查询

如果猜测1是正确的,那么您的问题是您使用的是json_编码而不是http_构建_查询

如果猜测2是正确的,那么您的问题是将数据添加到url查询中,而不是将其添加到请求体中,例如

$ch = curl_init('https://*hidden*.herokuapp.com/parse/classes/computers');
curl_setopt($ch,CURLOPT_POSTFIELDS,$query);
$ch = curl_init('https://*hidden*.herokuapp.com/parse/classes/computers');
curl_setopt($ch,CURLOPT_POSTFIELDS,$query);