基本上我需要获取给定 repo 的标签并将结果放在 php 数组中
我看过github API;返回一组标签,但我没有使用 cURL 的经验。
我认为网址是https://api.github.com/repos/joshf/MYREPO/git/refs/tag但我不确定如何将答案放入数组中
我找到了 GitHub API v2 的指南,但没有找到 v3
任何帮助,将不胜感激
编辑:
<?php
$url = "https://api.github.com/repos/joshf/Burden/git/refs/tags";
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "test");
$r=curl_exec($ch);
curl_close($ch);
echo $r;
$response_array = json_decode($r, true);
echo $response_array->{"ref"};
?>
给我
[{"ref":"refs/tags/1.2","url":"https://api.github.com/repos/joshf/Burden/git/refs/tags/1.2","object":{"sha":"d04eabe44b52e65ca2e1c1eaaca4321195d85001","type":"tag","url":"https://api.github.com/repos/joshf/Burden/git/tags/d04eabe44b52e65ca2e1c1eaaca4321195d85001"}},{"ref":"refs/tags/1.3","url":"https://api.github.com/repos/joshf/Burden/git/refs/tags/1.3","object":{"sha":"74d40e3f89717cbadc11e23e8ab4350d85deb015","type":"tag","url":"https://api.github.com/repos/joshf/Burden/git/tags/74d40e3f89717cbadc11e23e8ab4350d85deb015"}}]
我想要的只是标签的 1.2 和 1.3 位