PHP - 解析 - 错误":"必须至少指定一个 ID 字段 (installationId,deviceToken)
PHP - Parse - error":"at least one ID field (installationId,deviceToken) must be specified
我正在尝试获取基于用户 ID 字段的安装列表。目前这个 returns 错误 "at least one ID field (installationId,deviceToken) must be specified in this operation"
$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);
有人知道我错在哪里吗?
谢谢
您需要命名您的 $vars,并且仅将 'column' 更改为您尝试提取的列名。请注意,它在 spelling/capital 个字符中也必须相同。
<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>
您正在执行 POST 请求,而您应该执行 GET 请求,请参阅 https://www.parse.com/docs/rest/guide#queries-query-constraints
我正在尝试获取基于用户 ID 字段的安装列表。目前这个 returns 错误 "at least one ID field (installationId,deviceToken) must be specified in this operation"
$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);
有人知道我错在哪里吗?
谢谢
您需要命名您的 $vars,并且仅将 'column' 更改为您尝试提取的列名。请注意,它在 spelling/capital 个字符中也必须相同。
<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>
您正在执行 POST 请求,而您应该执行 GET 请求,请参阅 https://www.parse.com/docs/rest/guide#queries-query-constraints