【发布时间】:2021-11-07 15:06:54
【问题描述】:
我是 StackOverflow 的新手,所以如果我的格式不正确,我深表歉意。我正在使用 GitHub API,我的目标是在用户可以从中选择的下拉表单中获取用户存储库的列表。
假设存储库列表 URL 是 https://api.github.com/users/MY_GITHUB_USERNAME/repos(我坐下来的方式是通过执行 $userdata->repos_url 来获取存储库 URL)。当我使用以下内容时:
$curl1 = curl_init();
curl_setopt($curl1, CURLOPT_URL, $userdata->repos_url);
curl_setopt($curl1, CURLOPT_HEADER, 0);
curl_setopt($curl1, CURLOPT_HTTPHEADER, array(
'User-Agent: MY_WEBSITE_HERE Addon Developer OAuth'
));
curl_setopt($curl1,CURLOPT_USERAGENT,'User-Agent: MY_WEBSITE_HERE Addon Developer OAuth');
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl1, CURLOPT_SSL_VERIFYHOST, 0);
$cont1 = curl_exec($curl1);
curl_close($cont1);
echo $cont1;
它的响应如下:
[
{
(information I don't need)
"full_name": "github-username/this-is-what-i-want",
(information I don't need)
}
]
我目前只有一个存储库。我想要做的是制作一个只回显full_name 的代码,如果有多个数组回显每个。 (所有数组都有full_name。)
有人知道我该怎么做吗?
【问题讨论】:
标签: php github github-api