Giter Site home page Giter Site logo

Comments (13)

JiamingFB avatar JiamingFB commented on April 18, 2024 3

Hi arass,

Looks like you've got throttled for making too many api calls within short time. If you make tens of API calls within a few seconds, that could happen.

Suggested solution:

  1. Use AdAccount/Campaign/AdSet level insights and set 'level' to 'ad', so that you can get the insights of all ads in one HTTP request, instead of making one api call for each of the ads.
  2. Apply for higher access tier if eligible. This will increase your rate limit. You can see more details on https://developers.facebook.com/docs/marketing-api/access.

from facebook-java-business-sdk.

arass avatar arass commented on April 18, 2024 1

Was looking more into it. It seems that the cause is that even though I'm only making a few calls (<25) - the "cost" of these calls combined is higher than allowed?

So FB built an API that's useless to access Insights?

I can create a server/proxy farm that would cycle IPs, but was hoping someone had a better solution.
We can't wait hours to load a few stats on ads.
Seems like an epic fail on the part of FB.
Any suggestions?

from facebook-java-business-sdk.

arass avatar arass commented on April 18, 2024 1

from facebook-java-business-sdk.

arass avatar arass commented on April 18, 2024

Tried going through adsets before, but got killed on too many requests there also.

Went to the batch mode, for now, while we test (at least gets me a full set of insights). But your solution2 seems like the ultimate answer and is worth perusing. Thanks a lot! This makes more sense than encountering such a tiny rate limit and trying to work with it.

Much appreciated!

from facebook-java-business-sdk.

priyachetwani avatar priyachetwani commented on April 18, 2024

Hi arass,

Looks like you've got throttled for making too many api calls within short time. If you make tens of API calls within a few seconds, that could happen.

Suggested solution:

  1. Use AdAccount/Campaign/AdSet level insights and set 'level' to 'ad', so that you can get the insights of all ads in one HTTP request, instead of making one api call for each of the ads.
  2. Apply for higher access tier if eligible. This will increase your rate limit. You can see more details on https://developers.facebook.com/docs/marketing-api/access.

Yes he is right. accessing edges like adsets and ads directly from Ad_accounts node is better than accessing them individually . It would require less api requests.

from facebook-java-business-sdk.

priyachetwani avatar priyachetwani commented on April 18, 2024

Accessing edges like adsets and ads directly from Ad_accounts node is better than accessing them individually . It would require less api requests.

from facebook-java-business-sdk.

leopragi avatar leopragi commented on April 18, 2024

Just adding:

You can use expand fields

https://graph.facebook.com/v9.0/<ACCOUNT_ID>/ads?fields=name,account_id,id,insights.date_preset(yesterday){reach,impressions,clicks,cpc,cpm,cpp,ctr}

or

Insights api with account node with level

https://graph.facebook.com/v9.0/<ACCOUNT_ID>/insights?date_preset=yesterday&level=ad

This looks like a neat approach to me. I welcome suggestions!

from facebook-java-business-sdk.

mohitg8a avatar mohitg8a commented on April 18, 2024

How can I pass insights time_range? I have tried to pass this parameter but it does not work.

from facebook-java-business-sdk.

edt-andrew avatar edt-andrew commented on April 18, 2024

How can I pass insights time_range? I have tried to pass this parameter but it does not work.

in json:
params = {other params,
'time_range': '{"since":"yyyy-mm-dd","until":"yyyy-mm-dd"}'
}

url param:

&time_range={"since":"yyyy-mm-dd","until":"yyyy-mm-dd"}

from facebook-java-business-sdk.

mohitg8a avatar mohitg8a commented on April 18, 2024

Hello Andrew,

I want to pass multiple params, I have tried like this: insights(time_range={"since":"2021-07-14","until":"2021-07-14"},action_attribution_windows=['1d_click','1d_view','7d_view','7d_click']) but it's not work.

I am only able to pass one params at a time like this: insights.time_range({"since":"2021-07-14","until":"2021-07-14"}){reach,impressions,clicks,cpc,cpm,cpp,ctr}

Can you please help me with how can I pass multiple params?

I want to pass time_range and action_attribution_windows.

Thanks!

from facebook-java-business-sdk.

galacticgumshoe avatar galacticgumshoe commented on April 18, 2024

@mohitg8a Not sure posting a question unrelated to the closed issue is the right place for your answers. For insights, consider using the inner classes on the top-level class representing the level of insights you want to fetch (Campaign, AdAccount, etc). Those inner classes all say APIRequestGetInsights or APIRequestGetInsightsAsync. Pick whether you want to do a synchronous or asynchronous call. In my case, I need insights at the Ad Account level, so I use AdAccount.APIRequestGetInsights. If you look at those classes you'll see a bunch of setters which allow you to pass all of your various parameters before you call the .execute() on the sync class or the AdReportRun class for the async call. I initiate my own custom value object facebookAdsInsightsRequest (this is just a POJO I wrote that has all of the values in fields with getters/setters on them):

        FacebookAdsInsightsRequest facebookAdsInsightsRequest = new FacebookAdsInsightsRequest();
        facebookAdsInsightsRequest.setTimeRangeFormatted(startDate, endDate);
        facebookAdsInsightsRequest.set...

Then I can pass these fields into each of the setters on the APIRequestGetInsights class (this example is used to get all the campaigns that have some activity within the start and end date range for a given Ad Account):

        AdAccount.APIRequestGetInsights activeCampaigns = new AdAccount.APIRequestGetInsights(adAccountId, context);
        APINodeList<AdsInsights> adsInsights;
        try {
            activeCampaigns.setParam("level", facebookAdsInsightsRequest.getLevel())
                    .setParam("time_range", facebookAdsInsightsRequest.getTimeRangeFormatted())
                    .setParam("time_increment", facebookAdsInsightsRequest.getTimeIncrement())
                    .setParam("filtering", "[" + facebookAdsInsightsRequest.getCampaignFilterJson() + "]")
            activeCampaigns.setFields("campaign_id");
            adsInsights = activeCampaigns.execute().withAutoPaginationIterator(true);

            List<String> innerCount = new ArrayList<>();
            for (AdsInsights adsInsight : adsInsights) {
                String campaignId = adsInsight.getFieldCampaignId();
                if (campaignId != null) {
                    campaignIds.add(campaignId);
                    log.debug("Campaign ID {} has activity!", campaignId);
                    innerCount.add(campaignId);
                }
            }
        } catch (APIException e) { 
                    //do something with your exception here
        }

from facebook-java-business-sdk.

mohitg8a avatar mohitg8a commented on April 18, 2024

Thanks, it's really helpful for me.

Thank you again.

from facebook-java-business-sdk.

mohitg8a avatar mohitg8a commented on April 18, 2024

Hello Guys,

how can have a similar ad creative showing that they are being used in multiple ads?

We are building an internal reporting system for creative ads reporting. And we would like to know how can have the similar ad creative showing that they are being used in multiple ads similar to what FB does: https://prnt.sc/1qh0ezk

from facebook-java-business-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.