我正在构建与Google广告管理系统API交互的Rails 5 API,我需要一种方法来检索公司列表(也称为广告客户),以便可以使用它们来创建新订单以及最终的订单项
我无法在Ad Manager文档中找到它,不是红宝石,也不是其他语言。
我还没有任何代码,因为我不知道要使用什么服务。
我希望有一系列广告客户:[{:名称=>'公司1',:id =>'1234'},{:名称=>'公司2',:id =>'4321'} ]
任何帮助将不胜感激。我没能在Ad Manager文档中找到它,不是红宝石,也不是其他语言。
谢谢!
答案 0 :(得分:0)
我找到了答案。我错了,它是Ruby示例的一部分:
def get_advertisers(ad_manager)
company_service = ad_manager.service(:CompanyService, API_VERSION)
# Create a statement to select companies.
statement = ad_manager.new_statement_builder do |sb|
sb.where = 'type = :type'
sb.with_bind_variable('type', 'ADVERTISER')
end
# Retrieve a small amount of companies at a time, paging
# through until all companies have been retrieved.
page = {:total_result_set_size => 0}
begin
# Get the companies by statement.
page = company_service.get_companies_by_statement(
statement.to_statement()
)
# Print out some information for each company.
unless page[:results].nil?
page[:results].each_with_index do |company, index|
puts '%d) Company with ID %d, name "%s", and type "%s" was found.' %
[index + statement.offset, company[:id], company[:name],
company[:type]]
end
end
# Increase the statement offset by the page size to get the next page.
statement.offset += statement.limit
end while statement.offset < page[:total_result_set_size]
puts 'Total number of companies: %d' % page[:total_result_set_size]
end