我正在连接到rest api,它给我一次只有50个结果的json数据,我将结果保存在变量中,但我想要检索20000条记录,我想知道如何构建动态网址到获取所有数据并将其保存在变量中。
以下是我当前的代码
$url = "https://org.atlassian.net/rest/api/2/search?jql=project=PS+order+by+key&startAt=0";
$ch = curl_init();
$headers = array('Accept: application/json','Content-Type: application/json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$ch_error = curl_error($ch);
if ($ch_error) {
echo "cURL Error: $ch_error";
} else {
$json = json_decode($result, true);}
在我的网址中我有参数指定从哪个数字我可以返回记录,如第一个请求将是startAt = 0,第二个将是startAt = 51,thits将是startAt = 101或者我可以使用像x = total的公式没有记录/ 50然后运行curl x次并将所有结果保存在变量中或保存所有json数组然后合并它。请求我帮助我。
先谢谢
答案 0 :(得分:0)
有一个名为listagg
的查询参数,默认为50.您可以指定更高的数字。
maxResults(int):要返回的最大问题数(默认为50)。最大允许值由JIRA属性'jira.search.views.default.max'决定。如果您指定的值高于此数字,搜索结果将被截断。
https://docs.atlassian.com/jira/REST/cloud/#api/2/search-search
答案 1 :(得分:0)
我为此创建了一个循环并解决了问题。