Verwenden der benutzerdefinierten Such-API von Google

Möchten Sie Google Custom Search API in einer Anwendung (ios/android) implementieren? In Ordnung! Hier wird dieser Link alles für Sie lösen.

Geh und überprüfe das!

Geprüft? ‘Und zurück! Das bedeutet, dass Sie einer meiner Art sind, im Gegensatz zu den Genies, die die verschlüsselte Dokumentation dieser Technologiegiganten verstehen.

Ich brauchte 6-7 Stunden und Dutzende von URL-Schlüsseln (Support-URL und Forum-Links), um die bereitgestellte Dokumentation zu entschlüsseln. Ich möchte diese Zeit für euch aufsparen. Hier ist ein Schritt-für-Schritt-Prozess zur Implementierung der Google-Such-API.

Der erste X-Schritt ist für alle gleich, und die letzten paar Schritte sind für die Anwendungsentwickler bestimmt. In diesem Dokument erfahren Sie:

Steps to implement the search API
Pictorial detail of steps
Make a final run of your application

Kurzer Schritt des Prozesses:

Create a Google account (ignore if you have one)
You may found some peace of information related to pricing at the bottom of this page helpful(you can ignore this too)
Create project and generate API key 
Go to google consol and create a project
After project created, click on it to go to it's detail.
On the left bar under Auth&API segment, click on APIs.
Now you'll find CustomSearchAPI link in Brows APIs section (as it is not activated by default), turn it on by clicking on the button at right.
Now click on Credentials, just below APIs option
On this page under "Public API Access" click on Create New Key Button, for now choose browser key(as at first we wanna a test it on browser), create it and leave it, as it is for now.

Benutzerdefinierte Suchmaschine erstellen:

Now on the new tab, open Custom Search Engine page. On this page click on Create a custom search engine, button
That will lead you to create new search engine page, here give your domain name in "Sites to search" field. (If you don't have one no worries, give any thing, that have www. in the start and .com in the end)
Fill name, if it haven't pick one already, then click on create.
So you got a jumping robo to congratulate you? ;) Yeah that's it. In this page step up to "Modify your search engine", by clicking on, "Control Panel" button
There you are, now tern on the Image Search, (if you want to)
Also in "Sites to search" section, select, "Search the entire web but emphasize on included item", instead of, the default one, which is "Search only included site"
That is it at the bottom of this page click on update. And then come back to middle of the page and under the "Detail" title, click on Search engine ID, copy the Id, paste it somewhere.

Führen Sie eine Suche durch, indem Sie get request verwenden:

To make a get request use this request URL
In it replace, {API_KEY} which you have created under "Create project and generate API key" section
And replace {SEARCH_ENGINE_KEY} with the Search engine Id you just copy pasted
Call it with some different value, at query string, than 'a',  change a with any thing you wanna search you must have got the beautiful JSON of search result

Andere Sachen:

If you wanna see the request status, go back to your project page, that hoe may request placed, how many of those failed, ect. Click on the overview and you will get the graph for that, love you google
If you have trouble with JSON, here are some links at your service,
What is JSON 1, 2?
 Use JSON in ios.
 Use JSON in android. 


Google Custom Search: 403 error in iOS
My Blog: Use google Custom Search API
Stack Overflow post: Implementing Google custom search API in iOS

Similar Posts

Leave a Reply

Your email address will not be published.