Explorar el Código

marginalia api 502

lolcat hace 1 mes
padre
commit
5a7cecef11
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      scraper/marginalia.php

+ 10 - 0
scraper/marginalia.php

@@ -289,8 +289,18 @@ class marginalia{
 				throw new Exception("The API key used is rate limited. Please try again in a few minutes.");
 			}
 			
+			if(strpos($json, "<title>Bad Gateway (502)</title>")){
+				
+				throw new Exception("Marginalia returned a 502 error");
+			}
+			
 			$json = json_decode($json, true);
 			
+			if($json === null){
+				
+				throw new Exception("Failed to decode JSON");
+			}
+			
 			foreach($json["results"] as $result){
 				
 				$out["web"][] = [