def remote_read( self, batch=None, failure=None, fields=None, params=None, success=None, api_version=None, ): if self[self.__class__.Field.id]: _, image_hash = self[self.__class__.Field.id].split(':') account = AdAccount(fbid=self.get_parent_id_assured()) params = { 'hashes': [ image_hash, ], } images = account.get_ad_images(fields=fields, params=params) if images: self._set_data(images[0]._data)
'billing_event': 'IMPRESSIONS', 'bid_amount': '2', 'daily_budget': '1000', 'campaign_id': newcampaign["id"], 'targeting': {'excluded_geo_locations':{'regions':[{'key':'3847'}]},'geo_locations':{'countries':['US']}}, 'status': 'PAUSED', 'promoted_object': {'page_id':'1775351279446344'}, } print (AdAccount(id).create_ad_set( fields=fields, params=params, )) # get available images from an existing ad account account = AdAccount(id) images = account.get_ad_images() print(images[5]["hash"]) # create ad # hash image from facebook_business.adobjects.adimage import AdImage image = AdImage(parent_id=id) image[AdImage.Field.filename] = '/Users/justinshaw/Documents/herokuApps/fbapp01/image1.jpeg' image.remote_create() # Output image Hash print(image[AdImage.Field.hash]) #continue creating ad
def getHashImage(): FacebookAdsApi.init(app_id=dict1['my_app_id'] ,app_secret= dict1['my_app_secret'], account_id=dict1['account_id'] ,access_token=dict1['my_access_token']) fields = [] account = AdAccount(dict1['account_id']) campaigns = account.get_ad_images() print(campaigns)