facebook / facebook-php-business-sdk

PHP SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
833 stars 516 forks source link

AdInsight Fields now uses dot notation #471

Closed Smartsasse closed 5 years ago

Smartsasse commented 6 years ago

I did report this issue for 2.9.2 and it's still here but my issue got closed and I was told to report it again if I could still reproduce the issue. I would guess that this issue is for more than just the campaign name field. https://github.com/facebook/facebook-php-business-sdk/issues/370

Getting the following error when getting AdInsights with the following:

$insightsParams = [
    'level' => AdsInsightsLevelValues::ACCOUNT,
    'date_preset' => AdsInsightsDatePresetValues::LAST_30D,
    'filtering' => [
        [
            'field' => AdsInsightsFields::CAMPAIGN_NAME,
            'operator' => InsightsOperators::CONTAIN,
            'value' => 'Remarketing',
        ]
    ],
];

Error:

filtering on "Filter campaign_name is not valid any more, please use campaign.name instead

Version: facebook/php-business-sdk 3.0.0

https://github.com/facebook/facebook-php-ads-sdk/blob/c2e1e42eccfa65b78f8c2aca2415fbdddc545a8c/src/FacebookAds/Object/Fields/AdsInsightsFields.php#L51

jingping2015 commented 6 years ago

According to our doc https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group/insights/ The filtering param 's field is a string, it is not tied to any enum. So you can try with campaign.name which should solve your problem.

Smartsasse commented 6 years ago

I'm not saying that the API is broken. I'm using the string "campaign.name" right now and everything works fine. But this is an issue for this sdk, not for the api.

In the sdk there is a file for the AdsInsightsFields. If those constants would not be for this, could you please tell me what they are for and when you should use them. I'm pretty sure they are created to use like this and all I've used so long have worked fine, except "CAMPAIGN_NAME" which uses dot-notation. So the sdk should be updated to use the same dot-notation.

So I would be pleased if you could fix the constants in the following file:

https://github.com/facebook/facebook-php-business-sdk/blob/master/src/FacebookAds/Object/Fields/AdsInsightsFields.php

vicdus commented 6 years ago

Hi @Smartsasse ,

This class refer to "Field" enum in documentation https://developers.facebook.com/docs/marketing-api/reference/adgroup/insights/

Which is used to specify what field of ad insights you want to get from API GET request. It's not for parameter "filtering-fields" which is a free-form string

jingping2015 commented 5 years ago

Since we want to handle bugs more efficiently, we've decided to close issue reporting in Github and move to our dedicated bug reporting channel. If you encounter a bug with Business SDK (PHP), please report the issue at our developer bug reporting channel.