Comments (5)
How can I make it so all fields come back? What about an exclude
to do all fields except certain fields.
How is the behavior of get_default_read_fields
supposed to work? Is there a chance it's not fully implemented at this point?
from facebook-python-business-sdk.
If you read this by email, I updated the code in my original example
from facebook-python-business-sdk.
Hi tony, thanks for asking and hope you get well soon.
There's no way currently to read all fields. You have to manually specify the fields relevant to you when reading. You can find out more information about the fields in the online Ads API documentation.
The get_default_read_fields
class method simply returns the array of fields you may have specified using the set_default_read_fields
class method.
In the first remote_read call, the sdk will call get_default_read_fields because it sees you haven't specified a fields parameter:
AdAccount.set_default_read_fields([x,y,z])
my_ad_account = AdAccount(fbid="{your account fbid}")
my_ad_account_object.remote_read() # queries api to read fields x, y, and z
my_ad_account_object.remote_read(fields=[a, x] # queries api to read field a and x
Iteration also respects the default fields:
AdSet.set_default_read_fields([e,f,g])
my_ad_campaign = AdCampaign(fbid="{campagin id}")
my_ad_sets = my_ad_campaign.get_ad_sets() # when querying during iteration, will ask api to return ad set objects with the given fields e, f, and g
Does this resolve your issue?
P.S. I'm not sure what you're doing by specifying self.id or self in some places. I don't see any reference to self.
from facebook-python-business-sdk.
@archanl Thank you.
P.S. I'm not sure what you're doing by specifying self.id or self in some places. I don't see any reference to self.
Nevermind the self
, it code was originally an instance method on my side changed for example in the issue.
There's no way currently to read all fields. You have to manually specify the fields relevant to you when reading. You can find out more information about the fields in the online Ads API documentation.
Totally, what about the python side of things? I want a list of all the field class properties in facebookads.objects.AdSet.Field
, facebookads.objects.AdCampaign.Field
, etc so I can put them into a list set_default_read_fields
/ fields
would accept.
I'm trying to do something like it here:
[attr for attr in dir(fb_objects.AdCampaign.Field) if not callable(getattr(fb_objects.AdCampaign.Field, attr)) and not attr.startswith("__")]
.
The
get_default_read_fields clas
s method simply returns the array of fields you may have specified using theset_default_read_fields
class method.
When using AdAccount.set_default_read_fields([x,y,z])
, x
is a class property like fb_objects.AdSet.Field.bid_info
, or can it be bid_info
?
P.S. Unless you are open to altering / expanding the behavior a bit / have anything to ad, this is a solved case for me as I just went with declaring the fields by hand. It did take me time to understand it, so maybe I can PR some doc updates.
from facebook-python-business-sdk.
When using AdAccount.set_default_read_fields([x,y,z]), x is a class property like fb_objects.AdSet.Field.bid_info, or can it be bid_info?
fb_objects.AdSet.Field.bid_info
just evaluates to the string "bid_info". So x, y, and z can be either the full references to the string or hard coded strings if you don't care about code manageability.
P.S. Unless you are open to altering / expanding the behavior a bit / have anything to ad, this is a solved case for me as I just went with declaring the fields by hand. It did take me time to understand it, so maybe I can PR some doc updates.
Some work is indeed required regarding fields and field value enums. If you think you have a good solution to manage and retrieve fields well or can improve documentation, feel free to submit a pull request! One solution might be to use python 3 Enum module and its backport. Note that not all of an object's possible fields are always relevant when reading so it doesn't really make sense to read all fields. For example, an ad set may not have an end_date
.
from facebook-python-business-sdk.
Related Issues (20)
- fbMarketplace.com bruterforce attack
- Fb.me bruterforce attack
- [New Pages Experience] HOT 5
- Which versions of this Business SDK package correspond to the Marketing API versions? HOT 1
- Always got "The value must be a valid insights metric" error HOT 2
- Stub files
- typechecker.py does not handle <list<map<string, string>>> correctly. HOT 1
- facebook_business.adobjects.business.Business get_ad_network_analytics() ERROR HOT 3
- Meta API does not respond to requests, hosted on Azure HOT 3
- Error : Cannot include in summary param error message HOT 7
- Inconsistent Event Reporting - Unknown error HOT 3
- Pulling from ad tables(ads, ads_insights, campaigns, adsets etc... ) getting "Cannot include video_p100_watched_actions...
- Embecodon
- Where do I get the placement and site_source_name values in the SDK? HOT 5
- Api to count the total number of objects HOT 1
- Any function to get Call to Action options?
- API/Function through which I can get the Call to Actions Options HOT 2
- Call to Ads API doesn't throw error on failure. HOT 1
- Not able to access Business User Insights for multiple users using the Instagram API.
- Permission Error with creative_sourcing_spec
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facebook-python-business-sdk.