mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/11603] Split api_request into two functions (query only vs. full url)
PHPBB3-11603
This commit is contained in:
parent
92c55ab111
commit
a7af0134c0
1 changed files with 8 additions and 10 deletions
|
@ -143,17 +143,15 @@ function get_repository_url($username, $repository, $ssh = false)
|
||||||
return $url_base . $username . '/' . $repository . '.git';
|
return $url_base . $username . '/' . $repository . '.git';
|
||||||
}
|
}
|
||||||
|
|
||||||
function api_request($query, $full_url = false)
|
function api_request($query)
|
||||||
|
{
|
||||||
|
return api_url_request("https://api.github.com/$query?per_page=100");
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_url_request($url)
|
||||||
{
|
{
|
||||||
$c = curl_init();
|
$c = curl_init();
|
||||||
if ($full_url)
|
curl_setopt($c, CURLOPT_URL, $url);
|
||||||
{
|
|
||||||
curl_setopt($c, CURLOPT_URL, $query);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
curl_setopt($c, CURLOPT_URL, "https://api.github.com/$query?per_page=100");
|
|
||||||
}
|
|
||||||
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($c, CURLOPT_USERAGENT, 'phpBB/1.0');
|
curl_setopt($c, CURLOPT_USERAGENT, 'phpBB/1.0');
|
||||||
curl_setopt($c, CURLOPT_HEADER, true);
|
curl_setopt($c, CURLOPT_HEADER, true);
|
||||||
|
@ -177,7 +175,7 @@ function api_request($query, $full_url = false)
|
||||||
if ($rel == 'rel="next"')
|
if ($rel == 'rel="next"')
|
||||||
{
|
{
|
||||||
// Found a next link, follow it and merge the results
|
// Found a next link, follow it and merge the results
|
||||||
$sub_request_result = api_request(substr($url, 1, -1), true);
|
$sub_request_result = api_url_request(substr($url, 1, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue