def _RunTestWithBuffer(self, buffer_):
    """Tests error parsing using the given DfaSoapBuffer."""
    client = DfaClient(headers={
                           'Username': '******',
                           'Password': '******',
                           'AuthToken': 'password',
                           'appName': 'APP NAME'
                       }, path='/tmp/')

    with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
      service = client.GetSpotlightService()

    buffer_ = DfaSoapBuffer('1', True)
    buffer_.write(open(BUFFER_FILE_LOCATION).read())

    try:
      service._HandleLogsAndErrors(buffer_, '', '', {'data': 'datum'})
    except DfaApiError, e:
      self.assertEqual('That Activity Group Name or Tag String already exists.',
                       e.error_message)
      self.assertEqual(8304, e.code)
      self.assertEqual('Code 8304: That Activity Group Name or Tag String '
                       'already exists.', str(e))
Beispiel #2
0
import os
import sys
sys.path.insert(0, os.path.join('..', '..', '..', '..'))

# Import appropriate classes from the client library.
from adspygoogle import DfaClient


def main(client):
    # Initialize appropriate service.
    spotlight_service = client.GetSpotlightService(
        'https://advertisersapitest.doubleclick.net', 'v1.20')

    # Get activity types.
    results = spotlight_service.GetSpotlightActivityTypes()

    # Display activity type names and IDs.
    if results:
        for activity_type in results:
            print('Activity type with name \'%s\' and ID \'%s\' was found.' %
                  (activity_type['name'], activity_type['id']))
    else:
        print 'No activity types found.'


if __name__ == '__main__':
    # Initialize client object.
    client = DfaClient(path=os.path.join('..', '..', '..', '..'))
    main(client)
Beispiel #3
0
    authorize_url = flow.step1_get_authorize_url()

    print('Log in to your Google Account and open the following URL: \n%s\n' %
          authorize_url)
    print 'After approving the token enter the verification code (if specified).'
    code = raw_input('Code: ').strip()

    credential = None
    try:
        credential = flow.step2_exchange(code)
    except FlowExchangeError, e:
        sys.exit('Authentication has failed: %s' % e)

    # Create the DfpClient and set the OAuth2 credentials.
    client = DfaClient(headers={
        'Username': user_profile_name,
        'oauth2credentials': credential
    })

    # OAuth2 credentials objects can be reused
    credentials = client.oauth2credentials
    print 'OAuth2 authorization successful!'

    # OAuth2 credential objects can be refreshed via credentials.refresh() - the
    # access token expires after 1 hour.
    credentials.refresh(httplib2.Http())

    # Note: you could simply set the credentials as below and skip the previous
    # steps once access has been granted.
    client.oauth2credentials = credentials

    advertiser_service = client.GetAdvertiserService(version='v1.20')
Beispiel #4
0
    spotlight_dic = importFromExcel.read_spotlight_dic(file_path)

    # 初始化Service对象
    spotlight_service = client.GetSpotlightService(version='v1.20')

    # 根据导入的表格创建spotlight
    for i in range(len(spotlight_dic['spotlight_group_name'])):

        #分别获取spotlight_dict中每行的各参数值
        spotlight_group_name = spotlight_dic['spotlight_group_name'][i]
        spotlight_name = spotlight_dic['spotlight_name'][i]
        spotlight_type_id = spotlight_dic['spotlight_type_id'][i]
        tag_method_type_id = spotlight_dic['tag_method_type_id'][i]
        expected_url = spotlight_dic['expected_url'][i]
        image_enabled = spotlight_dic['image_enabled'][i]

        #首先创建Spotlight Group 并返回ID
        spotlight_group_id = create_spotlight_group(spotlight_service,
                                                    spotlight_group_name)
        create_spotlight(spotlight_service, spotlight_group_id, spotlight_name,
                         spotlight_type_id, tag_method_type_id, expected_url,
                         image_enabled)
    print 'The import task has finished!'


if __name__ == '__main__':
    # 初始化client对象
    client = DfaClient(path=HOME)
    main(client)
    os.system('pause')
# Import appropriate classes from the client library.
from adspygoogle import DfaClient


def main(client):
    # Initialize appropriate service.
    spotlight_service = client.GetSpotlightService(
        'https://advertisersapitest.doubleclick.net', 'v1.19')

    # Get method types.
    results = spotlight_service.GetSpotlightTagMethodTypes()

    # Display method type names and IDs.
    if results:
        for method_type in results:
            print('Method type with name \'%s\' and ID \'%s\' was found.' %
                  (method_type['name'], method_type['id']))
    else:
        print 'No method types found.'


if __name__ == '__main__':
    # Initialize client object. This example shows you how to put authentication
    # information into a client at initialization.
    client = DfaClient({
        'Username': '******',
        'Password': '******'
    })
    main(client)
  authorize_url = flow.step1_get_authorize_url()

  print ('Log in to your Google Account and open the following URL: \n%s\n' %
         authorize_url)
  print 'After approving the token enter the verification code (if specified).'
  code = raw_input('Code: ').strip()

  credential = None
  try:
    credential = flow.step2_exchange(code)
  except FlowExchangeError, e:
    sys.exit('Authentication has failed: %s' % e)

  # Create the DfaClient and set the OAuth2 credentials.
  client = DfaClient(headers={
      'Username': user_profile_name,
      'oauth2credentials': credential
  })

  # OAuth2 credentials objects can be reused
  credentials = client.oauth2credentials
  print 'OAuth2 authorization successful!'

  # OAuth2 credential objects can be refreshed via credentials.refresh() - the
  # access token expires after 1 hour.
  credentials.refresh(httplib2.Http())

  # Note: you could simply set the credentials as below and skip the previous
  # steps once access has been granted.
  client.oauth2credentials = credentials

  advertiser_service = client.GetAdvertiserService(version='v1.20')