Ejemplo n.º 1
0
    def handle(self, *args, **options):
        session = FacebookSession(
            os.environ['FB_GA_APPID'],
            os.environ['FB_GA_APPKEY'],
            os.environ['FB_GA_TOKEN'],
        )
        act_id = os.environ['FB_ACT_ID']
        tmp_dir = os.path.abspath(os.environ['GA_TEMP_DIR'])

        uploader = FacebookUploaderNoWait(FacebookAdsApi(session), act_id)
        storage = DjangoStorage()
        source = DropBoxSource(os.environ['DROPBOX_TOKEN'],
                               os.environ['GA_ROOT'])

        try:
            uploader.index()
            i = 5
            for f in source.get_files():
                i-=1
                if i == 0:
                    break

            self._print("All tests completed successfully")
        except Exception as e:
            self._print(f"Error: {str(e)}")
Ejemplo n.º 2
0
 def __init__(self, clientid, appsecret, token):
     session = FacebookSession(
             clientid,
             appsecret,
             token
     )
     self.api = FacebookAdsApi(session)
     self.object_queue = queue.Queue()
     self.batch = self.api.new_batch()
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        session = FacebookSession(
            os.environ['FB_GA_APPID'],
            os.environ['FB_GA_APPKEY'],
            os.environ['FB_GA_TOKEN'],
        )
        act_id = os.environ['FB_ACT_ID']
        tmp_dir = os.path.abspath(os.environ['GA_TEMP_DIR'])

        uploader = FacebookUploaderNoWait(FacebookAdsApi(session), act_id)
        storage = DjangoStorage()
        source = DropBoxSource(os.environ['DROPBOX_TOKEN'],
                               os.environ['GA_ROOT'])

        uploader = Uploader(storage, source, uploader, tmp_dir)
        uploader.run()
Ejemplo n.º 4
0
    def __init__(self, resource_path):
        config_filename = os.path.join(resource_path, 'config.json')
        config_file = open(config_filename)
        config = json.load(config_file)
        config_file.close()

        session = FacebookSession(
            config['app_id'],
            config['app_secret'],
            config['access_token'],
        )
        api = FacebookAdsApi(session)
        FacebookAdsApi.set_default_api(api)

        self.resource_path = resource_path
        self.api = api
        self.account_id = config['act_id']
        self.business_id = config['business_id']
        self.pageId = config['page_id']
Ejemplo n.º 5
0
import json
import os
import pprint

pp = pprint.PrettyPrinter(indent=4)
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()

### Setup session and api objects
session = FacebookSession(
    config['app_id'],
    config['app_secret'],
    config['access_token'],
)
api = FacebookAdsApi(session)

if __name__ == '__main__':
    FacebookAdsApi.set_default_api(api)

    print('\n\n\n********** Reading objects example. **********\n')

    ### Setup user and read the object from the server
    me = AdUser(fbid='me')

    ### Read user permissions
    print('>>> Reading permissions field of user:')
    pp.pprint(me.remote_read(fields=[AdUser.Field.permissions]))