在iOS中实施Google自定义搜索API [英] Implementing Google custom search API in iOS

查看:157
本文介绍了在iOS中实施Google自定义搜索API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了几个链接,以便找到在ios应用程序中实施google customsearchapi的正确步骤,并在此过程中花了大约6-7个小时。

I went through several links in order to find the proper steps to implement google customsearchapi in an ios application and spent about 6-7 hours in that process.

链接:

  • https://developers.google.com/custom-search/json-api/v1/introduction
  • http://developers.google.com/apis-explorer/#p/customsearch/v1/search.cse.list?q=a&_h=1&
  • https://productforums.google.com/forum/#!topic/customsearch/hT2fnfErVwo
  • Google Custom Search: 403 error in iOS
  • And Father of all

所有这些提供比特和和平的形成。有没有地方可以提供有助于在iOS应用程序中实现自定义搜索的摘要,精确信息?

All these provide bits and peaces of formation. Is there any place to have a summarize, precise info that can help to implement the custom search in an iOS application?

推荐答案

简短步骤:


  1. 创建一个Google帐户(如果有的话,请忽略)

  2. 您可能会在此页面有帮助(您也可以忽略此项目)

  3. 创建项目并生成API密钥

  1. Create a Google account (ignore if you have one)
  2. You may found some peace of information related to pricing at the bottom of this page helpful(you can ignore this too)
  3. Create project and generate API key

  1. 转到 google consol 并创建项目

  2. 创建项目后,单击它以查看其详细信息。

  3. 在Auth& API段下的左侧栏中,点击API。

  4. 现在你会找到 CustomSearchAPI 链接(因为默认情况下未激活),请点击右侧的按钮将其打开。

  5. 现在点击o n凭证,就在API选项下面

  6. 在Public API Access下的这个页面上点击Create New Key Button,现在选择浏览器密钥(首先我们想在浏览器上测试它) ),创建它并保留它,就像现在一样。

  1. Go to google consol and create a project
  2. After project created, click on it to go to it's detail.
  3. On the left bar under Auth&API segment, click on APIs.
  4. 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.
  5. Now click on Credentials, just below APIs option
  6. 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.


  • 创建自定义搜索引擎

  • Create Custom Search Engine


    1. 现在在新标签页上,打开自定义搜索引擎页面。在此页面上,点击创建自定义搜索引擎按钮

    2. 这将引导您创建新的搜索引擎页面,此处在要搜索的站点字段中提供您的域名。 (如果你没有一个没有担心,给任何东西,在开始时有www。和最后有.com)

    3. 填写名称,如果它没有选择一个已经,然后点击创建。

    4. 所以你有一个跳跃的机器人祝贺你? ;)是的,就是这样。在此页面中升级为修改您的搜索引擎,单击控制面板按钮

    5. 您现在打开图像搜索,(如果您愿意)

    6. 同样在要搜索的网站部分中,选择搜索整个网络但强调所包含的项目,而不是默认的仅搜索包含的网站

    7. 就是这样,在本页底部点击更新。然后回到页面中间并在详细信息标题下,单击搜索引擎ID,复制ID,将其粘贴到某处。

    1. Now on the new tab, open Custom Search Engine page. On this page click on Create a custom search engine, button
    2. 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)
    3. Fill name, if it haven't pick one already, then click on create.
    4. 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
    5. There you are, now turn on the Image Search, (if you want to)
    6. 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"
    7. 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.


  • 进行搜索,使用get request

  • Make a search, using get request:


    1. 要发出获取请求,请使用此请求网址

    2. 在其中替换,您在创建项目和下创建的{API_KEY}生成API密钥section

    3. 并将{SEARCH_ENGINE_KEY}替换为您刚刚复制粘贴的搜索引擎ID
      使用一些不同的值,在查询字符串中调用它,而不是'a', https://www.googleapis.com/customsearch/v1 q = a & key = {API_KEY}& cx = {SEARCH_ENGINE_KEY}更改任何你想搜索的东西你必须得到的搜索结果的忠实JSON

    1. To make a get request use this request URL
    2. In it replace, {API_KEY} which you have created under "Create project and generate API key" section
    3. 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', https://www.googleapis.com/customsearch/v1?q=a&key={API_KEY}&cx={SEARCH_ENGINE_KEY} change a with any thing you wanna search you must have got the beautiful JSON of search result


  • 其他东西

  • Other Stuff


    1. 如果你想看看请求状态,回到你的项目页面,如何请求放置,有多少失败,等等。点击概述,您将获得该图表,爱你谷歌

    2. 如果您在使用JSON时遇到问题,可以使用以下链接:

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

    1. 什么是JSON 1 2

    2. ios

    3. 机器人

    1. What is JSON 1, 2?
    2. Use JSON in ios.
    3. Use JSON in android.



  • 这篇关于在iOS中实施Google自定义搜索API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆