Closed kurko closed 2 years ago
Ad Set endpoint support Read-After-Write, so you can use it.
FacebookAds::Batch.with_batch do
5.times.map do |n|
ad_account.adsets.create(..., fields: %w[id name status])
end
end.execute
=> [#<FacebookAds::AdSet {:id=>"...", :name=>"...", :status=>"..."}>,
#<FacebookAds::AdSet {:id=>"...", :name=>"...", :status=>"..."}>,
#<FacebookAds::AdSet {:id=>"...", :name=>"...", :status=>"..."}>,
#<FacebookAds::AdSet {:id=>"...", :name=>"...", :status=>"..."}>,
#<FacebookAds::AdSet {:id=>"...", :name=>"...", :status=>"..."}>]
It's little bit hacky, but you also possible using Multiple ID Read Requests with this.
ids = [<ADSET_ID>, <ADSET_ID>, ...]
FacebookAds::APIRequest.new(
:get,
'',
params: { ids: ids.join(","), fields: "id,name,status" },
session: <SESSION>
).execute_now
=> #<FacebookAds::APIResponse:0x00007fd62c2fa008
@body=<BODY>,
@headers=<HEADERS>,
@status_code=<HTTP_STATUS>>
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Still waiting for some official answer
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Still waiting for some official answer
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Still waiting for some official answer
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
tl;dr there are 2 problems,
Batch
doesn't return a response with anything other than ids and the gem makes N requests for N attributes that are called on an object.Context
I'm creating many
AdSets
withFacebookAds::Batch.with_batch
. When I dobatch.execute
, I get back only ids:I need to access its
name
andstatus
(I want to double check that those were created correctly). When I doobject.first.name
, it makes Request1:Calling
object.first.status
, another request is made:The diff is the
fields
at the end. That led me to just load those ids with::FacebookAds::AdSet
The Problem
I want to load those records, so I do the following for each id:
::FacebookAds::AdSet.get('some-id-1', 'name,status,campaign_id', session)
That works, except that in reality I'm creating 3,000 ad sets for N customers. Facebook simply won't accept that many requests in serial. I tried using
FacebookAds::Batch.with_batch
to no avail.Questions
id
?object.name
and have it request N attributes at once, instead of one call per attribute? This is very inconvenient.Thanks a lot.