Hi

The reason, why I did not post all the code in the first place is that
it is so simple that I was sure that the problem did not come from my
code but from the right function(s) to use.

Turns out I found the problem after a couple of more hours:
My error was not in encoding the query data, but in decoding the
result. The whole time long, I sent the rightly encoded query to the
Google Image Search but failed to decode the results with the right
function. This left me with results that looked like the accurate
result for a wrong search - but they were in fact the wrong results
for the right search.

For others who might bump into the same problem:
A search term that has been entered into a form and that should be
transferred with the GET method and used in another php file, has to
be encoded with the encodeURIComponent() function in JavaScript before
being transmitted. Otherwise the search term will not even make it to
the significant code part in the php script. After being encoded that
way, the search terms can be handed over to the curl request sent to
Google simply like Jeremy stated above.

If you need to use this encoded search term(s) in a php-created html
link (for example to flip through search results one by one with the
help of a next-link) what you extracted from the URL needs to be
encoded with PHP's rawurlencode() before echoed into a href.

The results in the JSON string that you want to directly echo to your
page need to be decoded with PHP's utf8_decode() function.

This is what worked for me in the end.

Thanks Jeremy for your comments.
Later
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to Google-AJAX-Search-API@googlegroups.com
To unsubscribe from this group, send email to 
google-ajax-search-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to