我正在尝试使用google-ads-ruby库来允许我们的ruby on rails应用程序用户将我们的应用程序与谷歌广告连接起来,并从他们的账户中提取一些统计数据。我安装了gem并设法验证了用户并获得了refresh_token。
现在我正试着从谷歌上收集数据。
第一件失败的事情是their instructions在我的require 'google/ads/google_ads'代码中需要gem,我尝试将它添加到我的控制器中,并获得了cannot load such file -- google/ads/google_ads
然后,根据their instructions的说法,我应该能够运行以下代码:
client = Google::Ads::GoogleAds::GoogleAdsClient.new do |config|
config.client_id = Rails.application.secrets.google_oauth_client_id
config.client_secret = Rails.application.secrets.google_oauth_client_secret
config.developer_token = Rails.application.secrets.google_developer_token
config.refresh_token = @user.google_ads.refresh_token
end
accessible_customers = client.service.customer.list_accessible_customers().resource_names
accessible_customers.each do |resource_name|
puts "Customer resource name: #{resource_name}"
end然后列出,例如,用户的帐户as described here。
然而,我得到了uninitialized constant Google::Ads::GoogleAds
有人知道这是怎么回事吗?
发布于 2019-09-20 21:26:46
你试过了吗?
client = ::Google::Ads::GoogleAds::GoogleAdsClient.new do |config|
config.client_id = Rails.application.secrets.google_oauth_client_id
config.client_secret = Rails.application.secrets.google_oauth_client_secret
config.developer_token = Rails.application.secrets.google_developer_token
config.refresh_token = @user.google_ads.refresh_token结束
发布于 2019-09-23 05:05:14
这并不是对我问题的真正回答。我无法找到解决方案,但我做了进一步的挖掘,我发现谷歌添加到相同的gem和the documentation的AdsWords on Rails example app
这个应用程序有点过时,你可能会讨厌让它工作。此外,它是以一种非常隐秘的方式编写的,包含了如此多的函数,只是为了使用他们的API……但我能让它工作起来。老实说,应该有人写一篇教程。
希望这篇文章能给那些迷路的人一些线索。
https://stackoverflow.com/questions/58021622
复制相似问题