Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I create a Campaign, AdSet and Ad in one call? #18

Closed
roundrobin opened this issue Nov 23, 2017 · 6 comments
Closed

How can I create a Campaign, AdSet and Ad in one call? #18

roundrobin opened this issue Nov 23, 2017 · 6 comments
Labels

Comments

@roundrobin
Copy link

Is there a way to do that? Or do I have to created them one by one?

@mishrakrishnakant
Copy link

Wouldn't you just chain them up in a Promise chain?

@josescasanova
Copy link
Contributor

You can use the FacebookAdsApiBatch API (https://github.com/facebook/facebook-nodejs-ads-sdk/blob/master/src/api-batch.js#L17)

FB docs: https://developers.facebook.com/docs/marketing-api/asyncrequests/v2.11 (See Batch Requests midway through)

You can probably do something like:

const batch = new FacebookAdsApiBatch(facebookApi);

batch.add(
  'GET',
  'path/to/request/campaign',
  campaignSettings,
);

batch.add(
  'GET',
  'path/to/request/adset',
  adsetSettings,
);

batch.add(
  'GET',
  'path/to/request/ad',
  adSettings,
);

const response = await batch.execute();

@roundrobin
Copy link
Author

@josescasanova How does the adset/ad knows it belongs to the campaign added earlier to the batch request?

@WilliSchmidt
Copy link

WilliSchmidt commented Jun 22, 2019

@josescasanova How does the adset/ad knows it belongs to the campaign added earlier to the batch request?

https://developers.facebook.com/docs/graph-api/making-multiple-requests/#multiple_methods

Specifying dependencies between operations in the request:

{result=(parent operation name):(JSONPath expression)}

Example:

curl \
   -F 'access_token=...' \
   -F 'batch=[{ "method":"GET","name":"get-friends","relative_url":"me/friends?limit=5",},{"method":"GET","relative_url":"?ids={result=get-friends:$.data.*.id}"}]' \
   https://graph.facebook.com/

@stale
Copy link

stale bot commented Jan 14, 2020

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.

@stale stale bot added the Stale label Jan 14, 2020
@stale
Copy link

stale bot commented Jan 21, 2020

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.

@stale stale bot closed this as completed Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants