我找到了答案。我错了,它是 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