<s> """<STR_LIT>""" <EOL> from facebookads import FacebookSession <EOL> from facebookads import FacebookAdsApi <EOL> from facebookads . objects import ( <EOL> AdUser , <EOL> AdCampaign , <EOL> ) <EOL> import json <EOL> import os <EOL> import pprint <EOL> pp = pprint . PrettyPrinter ( indent = <NUM_LIT:4> ) <EOL> this_dir = os . path . dirname ( __file__ ) <EOL> config_filename = os . path . join ( this_dir , '<STR_LIT>' ) <EOL> config_file = open ( config_filename ) <EOL> config = json . load ( config_file ) <EOL> config_file . close ( ) <EOL> session = FacebookSession ( <EOL> config [ '<STR_LIT>' ] , <EOL> config [ '<STR_LIT>' ] , <EOL> config [ '<STR_LIT>' ] , <EOL> ) <EOL> api = FacebookAdsApi ( session ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> FacebookAdsApi . set_default_api ( api ) <EOL> print ( '<STR_LIT>' ) <EOL> me = AdUser ( fbid = '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> pp . pprint ( me . remote_read ( fields = [ AdUser . Field . permissions ] ) ) <EOL> my_account = me . get_ad_account ( ) <EOL> my_accounts_iterator = me . get_ad_accounts ( ) <EOL> print ( '<STR_LIT>' ) <EOL> for account in my_accounts_iterator : <EOL> pp . pprint ( account ) <EOL> print ( "<STR_LIT>" ) <EOL> for campaign in my_account . get_ad_campaigns ( fields = [ AdCampaign . Field . name ] ) : <EOL> for stat in campaign . get_stats ( fields = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) : <EOL> print ( campaign [ campaign . Field . name ] ) <EOL> for statfield in stat : <EOL> print ( "<STR_LIT>" % ( statfield , stat [ statfield ] ) ) </s>
