google custom search - php

cant quite find the answer I need so hopefully you guys can help.
I am trying to develop ( with basic but growing knowledge!) a split search bar for a custom cake website.
basically I have one search bar in the header, and a drop down with whole site and cakes in it.
When the whole site is selected I want it to pass the search parameters to googel custom search and display on the page. when cakes is selected it triggers a custom php search I wrote to search for and display a single cake picture.
I am doing this at the moment with an if statement. so if type=cakes then ( run php () else put search terms through google custom search.
Now I have tried using the results only format for it, but it doesnt seem to render anything! I dont know how to pass my parameter to the results page. I tried setting the parameter to cakeref which is what i have specified previously.
Any help or explanations as to how google custom search works and integrates would be amazing.

Try this
$search_query = "Is+Wikipedia+IsGreat";
$amazon_url = "https://www.googleapis.com/customsearch/v1?key=3425lh43lkh52lk34jh5&cx=023470239740:kj2h3kl4hlk23&alt=atom&num=5&q='$search_query'";
$google_search = file_get_contents($amazon_url);
You need API Key and CX number for calling this API. And urlencoding to encode query parameters.
Try Curl also..
API Client Library is here
http://code.google.com/p/google-api-php-client/
http://code.google.com/p/google-api-php-client/source/browse/trunk/examples/customSearch/index.php
http://www.phpclasses.org/package/6301-PHP-Perform-searches-with-the-Google-Site-Search-API.html

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.

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

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

how to submit jsf form with curl

I am new to Java and JSF,
I was looking for some way to send a query term to toysrus.co.uk
I have already worked on php curl and I can handle it at my own, and I have coded my function which sends query term...
My issue is I am unable to create the query term and and I cant find a way to create a url in which I can add my query parameter so that I can curl this page.....
can somebody guide me how I can create the search url for toysrus.co.uk
what I want is, I will add my parameter in URL and the curl script will send this request to the site and I will get the searched product...
I want something like
http://www.toysrus.co.uk/index.jsf?seach=MYTERM
this is just an example what I want...
can somebody help me create the search URL for the said web site? being totally new to JSF, I am unable to do it...
also, when I googled on JSF and tried searching for helping material, I found not enough stuff on JSF
thanks for help..
You should be able to search the site just by changing the search term in the URL query string.
I went to the main page and typed "seriously" into the search box. Here's the address it sent me to:
http://www.toysrus.co.uk/index.jsf?fh_eds=%3f&fh_view_size=10&fh_start_index=0&fh_location=%2f%2ftrus%2fen_GB%2fcategories%3C%7btrus_trus%7d%2fitemtype%3dproduct%2f%24s%3dseriously&media=web
See where the search term shows up there? You can change that to any other word and it will search for that. Want to search for multiple terms, or a phrase? Try typing them into the search box and see how they're encoded in the URL. You can probably also remove or change some of those other parameters if you experiment with it.

How to set the google custom search to dispaly the results of search on a paticular page like search.php?

I have implemented google custom search engine on my website http://www.finalyearondesk.com/
What I want is that when user enters his query into my own defined search bar, then the results [By result I mean the result that is displayed right after just entering the query and hitting enter, for example "ubuntu"] must be displayed in this page... http://www.finalyearondesk.com/search.php . At now the result are just displayed where I have inserted the code that google has given me.
The Google custom search is a JavaScript Ajax widget. The browser talks to Google independent of your site.
If you want results in your search.php page, either put the search-box on the search.php page, or query Google server side, then display the formatted results any way you like. This is very not ideal because Google limits the number of queries you can do.
Long story short, you have to live with the ads and limited placement options google gives you.
You can always attempt to write your own web search engine if you don't like it [/sarcasm]

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

Categories