【问题标题】:Rails google-ads-ruby setting upRails google-ads-ruby 设置
【发布时间】:2019-09-23 05:05:14
【问题描述】:

我正在尝试使用 google-ads-ruby 库来允许我们的 ruby​​ on rails 应用程序用户将我们的应用程序与 Google Ads 连接起来,并为他们从他们的帐户中提取一些统计信息。 我安装了 gem 并设法对用户进行身份验证并获取 refresh_token。

现在我正在尝试开始从 Google 收集数据。

失败的第一件事是 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

有人知道怎么回事吗?

【问题讨论】:

    标签: ruby-on-rails ruby google-ads-api


    【解决方案1】:

    你试过了吗?

    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
    

    结束

    【讨论】:

      【解决方案2】:

      这并不是我的问题的真正答案。我无法找到解决方案,但进行了更多挖掘,我发现 AdsWords on Rails example app Google 添加到同一个 gem 和 the documentation

      该应用程序有些过时,您可能会讨厌让它工作。此外,它是以一种非常神秘的方式编写的,并且包含许多功能只是为了使用它们的 API ......但我能够让它工作。老实说,应该有人写教程。

      希望这可以为在某个时候迷路的人提供一些线索。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-04
        相关资源
        最近更新 更多