我是 REST 的新手,并试图SELECT ID from CO.A_Country where Name="xxx";
使用 ROQL 从查询中获取 ID。我将 REST 与 PHP 一起使用:
<?php
/**
* Example API call
* GET profile information
*/
// the ID of the profile
$profileID = 2;
// the token
$token = 'your token here';
// set up the curl resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"https://User:Pass@test.help.com/services/rest/connect/v1.3/queryResults
/?query=select%20ID%20from%20CO.A_Country%20where%20CO.A_Country.A_Country=%27xxx%27");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$output = curl_exec($ch);
echo($output). PHP_EOL;
curl_close($ch);
?>
我得到以下结果:
HTTP/1.1 200 OK Date: Thu, 04 Aug 2016 14:58:02 GMT Server: Apache Content-Language: en-US RNT-Time: D=58455 t=1470322682582920 RNT-Machine: 128.64 Transfer-Encoding: chunked Content-Type: application/json { "items": [ { "tableName": "CO.Affected_Country", "count": 1, "columnNames": [ "id" ], "rows": [ [ "12" ] ] } ], "links": [ { "rel": "self", "href": "https://test.help.com/services/rest/connect/v1.3/queryResults?query=select%20ID%20from%20CO.A_Country%20where%20CO.A_Country.Affected_Country=%27USA%27" }, { "rel": "canonical", "href": "https://test.help.com/services/rest/connect/v1.3/queryResults" }, { "rel": "describedby", "href": "https://test.help.com/services/rest/connect/v1.3/metadata-catalog/queryResults", "mediaType": "application/schema+json" } ] }
如何仅获取所需的 ID 以在 $output 中?