How to get a JSON response from a Google Image Search? - php

All I want to do is a simple Google Images search. We were doing the old, really, incredibly simple way using the now completely deprecated JSON Image Search API.
That page now says it is included in Google Custom Search. The problem is that I don't want to search my own website, I want to search the web for images still. I cannot, for the life of me, find what the new way to do this is.
I have tried the Google API for PHP, it also works only with Custom Search which is only for searches on my website and not the entire web.
I have tried it using https://www.googleapis.com/customsearch/v1?key=MYKEY&cx=MYCX&q=candy and it's still searching our website only not the web in general.
Can someone point me to a documentation page that describes how to use an API to do an image search on the web in general and get results in the JSON?

You can indeed use the Google API for PHP. You just need to configure your custom search engine to search the entire web. To do this, login to your CSE settings at https://cse.google.com/cse/, and remove all sites.
Then, change 'Sites to search' to 'Search the entire web but emphasize included sites'.
Since you don't have any sites specified, it will just search the whole web.
You can test using the box on the right.
As for documentation, the CSE API is documented here https://developers.google.com/custom-search/json-api/v1/reference/cse/list#parameters

Related

I'd like to make search page

I'm going to make search page in website using google search engine.
I'm using laravel 5.4 framework.
So I got the Google Custom Search API key.
And I created new google search engine here.
I got the search engine ID.
And I used "jan-drda/laravel-google-custom-search-engine" package for searching.
I can get the search result. but result is limited to lists of url that I
inserted in custom search engine.
How can I get the result same as google search result?
In other words, how can I search without searching url limitation.
I hope that make sense.
Remove all the urls entered in "Sites to Search" from and you will have the search returned from whole web.
Note: The results on main google search and results via google API, results would still vary.

Box.com API 2 - search from website & present results from folder

Quick question... (for a PHP intranet I am creating).
Is it possible to search documents in a Box.com account using their API 2???
Ideally I'd like to:
Search Box.com from within the intranet (a port is open to the outside world).
Present the results from a Box.com folder, as document titles that are links to download the document.
Any hint's or even just a link or 2 that 'totally' confirms this is possible would be really appreciated - as I have been hearing conflicting answers that this is & isn't possible.
Thanks ;-)
Yes, it is possible to search a Box.com account through the API. See the documentation at http://developers.box.com/docs/#search
However, I don't think you can restrict the search to a single folder at present: you have to be logged in to Box to do the search and the only documented options are the search term and some control over how many results are returned. The documentation does say they will add filters but if you can filter results right now there's nothing in the documentation about it.

Get restaurant reviews from other review sites

I am building a restaurant review site using php. I wanted to know how to show reviews from other reviews sites. For example check this link to see how google is picking up reviews from other sites. When clicked on, it takes you to their review site.
Any help will be appreciated. Thanks
First, make a list of the sites that you want to pull reviews from. Second, read through those sites and see if they have a developer section and if they expose a public API. If they do, look around to see if they have any client libraries for php which you can use to access their API from your php site. If they do have an API but there are no client libraries available, contribute to the community by creating a client library and sharing it as open source. :)
Also, it may be possible that they have an RSS feed of their reviews that you can consume easily of your site, so check that out too.
You will probably find the other sites have partnered with Google for this, however I would be using cURL to get the information you want.
I would suggest you start here with cURL, then have a look here to extract the portion you're looking for.
Edit: the section of the second link that is relevant is
preg_match_all("/<div>.+<\/div>/", $page, $matches);
print_r($matches);
What this is doing is getting the content you're looking for and then displaying it, you will probably need to define the unique elements with the content you want however, this could mean a separate rule for each website.
I hope this helps for you.
I think google find News, Blog , Reviews and something like that by site map what web administrators introduce to google as sitemap.xml .
To do this you must get page content what you want to fetch it's reviews ( By CURL or something like that to get remote file ) and fetch reviews by regular expression of HTML

Google custom site search via XML...how to get the "did you mean..." value?

I am developing a search solution for my photo community web application. I am making use of Google Site Search. There are various ways to make use of it, but because I want a seamless fit with custom search result rendering, I went for the XML option.
It works really simple. I have a custom-styled search box on the site which posts to my back-end, a CodeIgniter PHP controller. The controller then will do a GET to the Google Site Search XML service, which returns me the search results in XML.
It works brilliantly and gives me full control over output rendering. There is just one little thing missing. If I search for a misspelled word, let's say "crocodilw" (should be "crocodile") I would like to get the "did you mean "crocodile?" functionality that is so common in Google.
This feature does work when you use the front-end integration method of Google Site Search. I kind of expected the correct search suggestion to be part of the return XML as well, but I can't seem to find it.
Any clues on how/if this is possible using the XML method?
This will only work on the first page (start=0) of the results. On the second page, it's gone.
http://www.google.com/cse/docs/resultsxml.html#results_xml_tag_Spelling

How to implement a Search Box Process in my HTML Website?

I am looking for a means of implementing a "Search" routine/page that I can apply to my site that is purely a HTML website only.
I have provided a Search box for the user but unsure what the next step is, i.e. can I insert php to perform the Search of my site.
You could set up a Google Custom Search. It has the functionality of a Google Search, it is customizable, and it is really easy to set up. All you need is a site and a Google Account.
Here's how you get started:
http://code.google.com/intl/en/apis/customsearch/docs/start.html

Categories