def page_remote_view(cts, scope, id=None, token=None): from oozer.common.facebook_api import PlatformApiContext, get_default_fields from facebook_business.adobjects.user import User if not token: scope = AssetScope.get(scope) token = PlatformToken.get(list(scope.platform_token_ids)[0]) with PlatformApiContext(token.token) as fb_ctx: pages = User(fbid='me', api=fb_ctx.api).get_accounts() for page in pages: print(page)
def ad_account_remote_view(cts, scope, id, token=None): from oozer.common.facebook_api import PlatformApiContext, get_default_fields from common.enums.entity import Entity if not token: scope = AssetScope.get(scope) token = PlatformToken.get(list(scope.platform_token_ids)[0]) with PlatformApiContext(token.token) as fb_ctx: ad_account = fb_ctx.to_fb_model(id, Entity.AdAccount) fields = get_default_fields(ad_account.__class__) ad_account_with_selected_fields = ad_account.api_get( fields=['id', 'name']) # Read just the fields we need ad_account_data_dict = ad_account_with_selected_fields.export_all_data( ) # Export the object to a dict print(ad_account_data_dict)
def scope_model(self): from common.store.scope import AssetScope return AssetScope.get(self.scope)