代码之家  ›  专栏  ›  技术社区  ›  Daniel Ribeiro

工作(没有401客户端错误)非官方的Google API阅读器客户端

  •  1
  • Daniel Ribeiro  · 技术社区  · 15 年前

    是否有一个工作客户机(任何语言,最好是Ruby语言)可以 目前 从,仍然是非官方的 Google Reader API ?

    我都试过了 this this 但他们似乎无法提出简单的请求,例如 http://www.google.com/reader/api/0/subscription/list ,如果在浏览器上使用,它将非常有效。

    1 回复  |  直到 13 年前
        1
  •  1
  •   Ben    13 年前

    我回答说,这是我发现与这篇文章相似的其他几篇文章…因此,如果与Ruby相关,使用Google API客户端(对于任何Google API),那么在使用API密钥时,与使用OAuth相比,存在一些带有身份验证的出入……

    我已经在下面概述了这个过程(使用API密钥服务器端) the code abode .

    在构建客户机时,必须显式地将authorization参数设置为nil,否则gem将尝试使用OAuth进行身份验证,因此,如果仅使用API密钥从服务器调用,则始终会获得401未经授权。 the code abode - google-api-client for ruby

      require 'openssl'
      OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
    
      require 'google/api_client'
      client = Google::APIClient.new(:key => 'your-api-key', :authorization => nil)
      search = client.discovered_api('customsearch')
    
      response = client.execute(
        :api_method => search.cse.list,
        :parameters => {
          'q' => 'the hoff',
          'key' => 'your-api-key',
          'cx' => 'your-custom-search-id'
        }
      )
    
    推荐文章