diff --git a/index.php b/index.php index d9ef115..2ed1010 100644 --- a/index.php +++ b/index.php @@ -348,7 +348,8 @@ function updateGitKeys($api, $keys) function apiRequest($api, $route, $meth = 'GET', $data = null) { $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $api['api'].'/'.$route); + $url = $api['api'].'/'.$route; + curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $meth); curl_setopt($ch, CURLOPT_USERAGENT, 'Machines Frogeye'); if ($data) { @@ -366,7 +367,12 @@ function updateGitKeys($api, $keys) curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $raw = curl_exec($ch); curl_close($ch); - return json_decode($raw); + $json = json_decode($raw); + if ($json !== null && isset($json->{"error"})) { + echo("Error with API ".$url.": ".$json->{"error"}."\n"); + return null; + } + return $json; } global $SSH_KEY_REGEX; @@ -403,7 +409,6 @@ function updateGitKeys($api, $keys) } foreach ($toDelete as $id => $ekey) { - echo "387 deleting $id $ekey\n"; apiRequest($api, 'user/keys/'.$id, 'DELETE'); } } @@ -657,7 +662,7 @@ case 'config': foreach ($machines as $dMachineName => $dMachine) { if ($network['secure'] == 'true') { - + } }