2013-08-21 64 views
1

我運行安裝了rbing寶石軌道4(1.1.0版本)rbing未定義的方法網

require 'rbing' 
bing = RBing.new("YOURAPPID") 

rsp = bing.web("ruby", :site => "github.com") 
puts rsp.web.results[0].url 

就像這裏的例子: https://github.com/mikedemers/rbing

當我運行它,我得到這個錯誤:

undefined method `web' for # RBing::ResponseData:0x007f42500bb190

+0

你是否在bing = RBing.new(「YOURAPPID」)中設置了一個真實的應用程序ID?我認爲你應該用一個真實的ID替換YOURAPPID :) – Bigxiang

+0

我使用一個真實的應用程序ID,但我不打算在論壇上發佈它。感謝您對此進行調查。我從這裏得到了我的應用程序ID - www.bing.com/developers/createapp.aspx – gmaniac

回答

1

我結束了使用谷歌,而不是

client = Google::APIClient.new(:authorization => nil) 

google_search = client.discovered_api('customsearch', 'v1') 

google_result = client.execute(
     :api_method => google_search.cse.list, 
     :authenticated => false, 
     :parameters => { 
      'q' => query, 
      'key' => key, # your key received from google 
      'siteSearch' => query_params[1], 
      'cx' => cx, # your cx code received from google 
      'num' => 1 
     } 
    )