Browse Source

handle google api no results

lolcat 10 tháng trước cách đây
mục cha
commit
560b9b04da
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      scraper/google_api.php

+ 3 - 2
scraper/google_api.php

@@ -570,7 +570,7 @@ class google_api{
 			"video" => [],
 			"news" => [],
 			"related" => []
-		];		
+		];
 		
 		if(isset($json["error"]["message"])){
 			
@@ -583,7 +583,8 @@ class google_api{
 		
 		if(!isset($json["items"])){
 			
-			throw new Exception("Failed to access items array");
+			// google just doesnt return items when theres no results
+			return $out;
 		}
 		
 		foreach($json["items"] as $result){