我正在尝试根据userID字段获取安装列表。目前,这将返回错误“必须在此操作中指定至少一个ID字段(installationId,deviceToken)”
$url = 'https://api.parse.com/1/installations';
$user_id = "3014";
$APPLICATION_ID = 'xxxxxxxxxxxxxxxx';
$REST_API_KEY = 'xxxxxxxxxxxxxxxx';
$MASTER_KEY = 'xxxxxxxxxxxxxxxx';
$data = array
(
"where" => array(
"userID" => $user_id,
),
);
$_data = json_encode($data);
$headers = array(
'Content-Type: application/json',
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'X-Parse-Master-Key: ' . $MASTER_KEY,
'Content-Length: ' . strlen($_data),
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_PORT, 443);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec($curl);
var_dump($response);
curl_close($ch);
有人知道我哪里出错吗?
由于
答案 0 :(得分:0)
您需要为$ vars命名,并且只将“列”更改为您尝试提取的列名称。请注意,拼写/大写字母也必须相同。
<html>
<head>
<style>
td {
text-align:center;
border: 1px solid black;
}
</style>
</head>
<body>
<?php
include_once 'DB.Connect.php';
// error_reporting(E_ALL);
$url="http://url.com"
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$json = curl_exec($ch);
curl_close($ch);
$DataA = json_decode($json, TRUE);
$c = 0;
echo '<center><table>';
echo '<tr><th>Title</th></tr>';
foreach ($DataA as $data) {
$var = $DataA[$c]['column'];
echo '<tr>';
echo '<td>'.$DataA[$c]['column'].'</td>';
echo '<td>None</td>';
echo '<td></td>';
echo '</tr>';
}
$c++;
?>
</body>
</html>
答案 1 :(得分:0)
您正在执行POST请求,您应该在其中执行GET请求,请参阅https://www.parse.com/docs/rest/guide#queries-query-constraints