Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Custom Search for Image Returns 500 Error

Started about 40 hours ago, Google Custom Search when used for image search (searchType=image) always returns 500 error. I have double checked with the APIs documentation and there seems to be no change. This is affecting quite a lot of people as you can see in this forum.

https://productforums.google.com/forum/#!category-topic/customsearch/troubleshooting-and-bugs/4bJPzGPLYfw

This is all I get back in the response:

{
   "error": {
       "code": 500,
       "message": null
   }
}

I have tried calling Google, but they just kept redirecting me to the website where there is absolutely no information relating to this.

Has anyone managed to get this to work or have spoken to a person at Google? We are heavily using this feature and it's very costly to have it down for this long.

like image 223
juminoz Avatar asked Dec 10 '14 21:12

juminoz


1 Answers

We worked around it by removing the searchType=image, and changing the code to traverse the json. The code change below conveys the idea:

from:

$.each(response.items, function(index, item) {
      images.push(item.link);
  });

to:

  $.each(response.items, function(index, item) {
    if ((item.pagemap) && (item.pagemap.cse_image) && (item.pagemap.cse_image[0]) && (item.pagemap.cse_image[0].src)) {
      images.push(item.pagemap.cse_image[0].src);
    }
  });

Hope that helps.

Ps: Not cool, Google, not cool.

EDIT: The above workaround probably isn't what you're searching for since Google Custom Search (CSE) for Images is working again (was out for around 3 days, back on +/- 12/12/2014).

like image 50
Paul-Armand Verhaegen Avatar answered Oct 19 '22 10:10

Paul-Armand Verhaegen