From a7af0134c0cdd5577a094e78ddae258711591b10 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 13 Jun 2013 18:43:04 +0200 Subject: [PATCH] [ticket/11603] Split api_request into two functions (query only vs. full url) PHPBB3-11603 --- git-tools/setup_github_network.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php index 3f1f61b288..c24968c7c2 100755 --- a/git-tools/setup_github_network.php +++ b/git-tools/setup_github_network.php @@ -143,17 +143,15 @@ function get_repository_url($username, $repository, $ssh = false) 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(); - if ($full_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_URL, $url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_USERAGENT, 'phpBB/1.0'); curl_setopt($c, CURLOPT_HEADER, true); @@ -177,7 +175,7 @@ function api_request($query, $full_url = false) if ($rel == 'rel="next"') { // 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)); } } }