Closed rabochoval closed 5 years ago
Hi there,
The Python samples are designed to read necessary values from the command line, there's no need to hardcode anything. Ex:
$ python get_campaigns.py 8888
Regards, - Jonathon Imperiosi, DCM API Team
Hi there,
thanks a lot, it works perfect. but still if I want to hardcode, any link with example?
I don't have anything to link to, but at a high level you'd probably want to:
profile_id = flags.profile_id
becomes
profile_id = 8888
Regards, - Jonathon Imperiosi, DCM API Team
Thanks a lot, it is working now.
Hi,
I just started with DCM API and need to get list of all campaigns, I also find my profile_id, let say, my profile_id is '8888' Can you please confirm the below code? Because I'm still getting error that the following arguments are required: 8888, is should be int. Am I missing something? It should be straight forward task. Thanks a lot, Lucie
import argparse import sys
import dfareporting_utils from oauth2client import client
profile_id = '8888'
Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False) argparser.add_argument( profile_id, type=int, help='The ID of the profile to look up advertisers for')
def main(argv):
Retrieve command line arguments.
flags = dfareporting_utils.get_arguments(argv, doc, parents=[argparser])
Authenticate and construct service.
service = dfareporting_utils.setup(flags)
profile_id = flags.profile_id
try:
Construct the request.
except client.AccessTokenRefreshError: print ('The credentials have been revoked or expired, please re-run the ' 'application to re-authorize')
if name == 'main': main(sys.argv)