Ruby 谷歌知识图认证

Ruby 谷歌知识图认证,ruby,google-api,google-knowledge-graph,Ruby,Google Api,Google Knowledge Graph,我正在尝试使用谷歌知识图API。我已经有了API密钥,并且还使用了库而不是RESTful API kgSearch = Kgsearch::KgsearchService.new response = kgSearch.search_entities(query: query) 我已尝试按如下方式实例化该服务 kgSearch = Kgsearch::KgsearchService.new(api: 'klfkdlfkdlm') 它被拒绝,因为init不需要参数 你知道如何添加api_密钥吗

我正在尝试使用谷歌知识图API。我已经有了API密钥,并且还使用了库而不是RESTful API

kgSearch = Kgsearch::KgsearchService.new
response = kgSearch.search_entities(query: query)
我已尝试按如下方式实例化该服务

kgSearch = Kgsearch::KgsearchService.new(api: 'klfkdlfkdlm')
它被拒绝,因为init不需要参数

你知道如何添加api_密钥吗

我还尝试:

response = kgSearch.search_entities(query: query, api: 'fjfkjfl')
同样的事情


有什么想法吗?

根据谷歌Api客户端的Ruby文档,
key
是一种实例方法,您可以在其中分配Api密钥()

所以我相信你会做如下的事情:

kgSearch = Kgsearch::KgsearchService.new
kgSearch.key = 'your_key_here'
response = kgSearch.search_entities(query: query) # and any other options that are necessary

根据谷歌Api客户端的Ruby文档,
key
是一种实例方法,您可以在其中分配Api密钥()

所以我相信你会做如下的事情:

kgSearch = Kgsearch::KgsearchService.new
kgSearch.key = 'your_key_here'
response = kgSearch.search_entities(query: query) # and any other options that are necessary