php - Gitlab:使用Since属性过滤提交也会给出较旧的提交
问题描述
我试图只获得这一天的提交。我正在使用 CURL 发出请求。我已经尝试过 ISO 8601 和 RFC3339,但都没有产生我想要的结果。
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://gitlab.example.com/api/v4/projects/ID/repository/commits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Private-Token: PRIVATE-TOKEN",
"since: 2018-09-03T00:00:00Z",
"until: 2018-09-04T00:00:00Z"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$commits = $response;
print_r($commits);
解决方案
我发现为了使它起作用,since 参数(以及与此相关的任何其他可选参数)需要在 url 中;
https://gitlab.example.com/api/v4/projects/ID/repository/commits?since=2018-09-03T00:00:00Z&until=2018-09-04T00:00:00Z
而不是像我一直在做的那样在标题中。
推荐阅读
- mongodb - 如何在不创建空/空字符串的情况下存储多个 Outh2 id?
- reactjs - 下一张图片未在小屏幕上显示
- css - CSS 半滚动 vs 半固定
- javascript - 将文本从星号切换到普通文本
- python - 在数周内抓取时列出超出范围的索引
- java - 如何解决 java.lang.NullPointerException 问题?
- wordpress - htaccess 裸 url 重定向到具有特定查询字符串的路径
- python - 当超级用户是发件人时,Django post-save
- amazon-cognito - Cognito 应用程序 AWS SAM CLI 构建错误
- python - 如何知道 Spotify 访问令牌何时过期并知道何时应该刷新