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

Error from AdAccount when calling throught Campaign Object #432

Closed ebisbe closed 6 years ago

ebisbe commented 6 years ago

Hello,

I got the following error:

FacebookAds\Http\Exception\AuthorizationException : (#100) 
Tried accessing nonexisting field (configured_status) on node type (AdAccount)

With the following code:

$campaign = new Campaign(self::SANDBOX_AD_ACCOUNT);

        $campaign->setData([
            CampaignFields::NAME => 'My campaign',
            CampaignFields::OBJECTIVE => CampaignObjectiveValues::LINK_CLICKS,
        ]);

        $campaign->update([
            Campaign::STATUS_PARAM_NAME => Campaign::STATUS_PAUSED,
        ]);

        $campaign->read([
            CampaignFields::CONFIGURED_STATUS,
            CampaignFields::EFFECTIVE_STATUS,
        ])->exportData();

I don't understand why it says on node type (AdAccount) when I'm clearly calling it from the Campaign object ( from sandbox Ad Account). I'm just trying to verify in a Test that the campaign status has been updated correctly. I'm not sure it's a good practice to do that test but I'm trying to understand how it works this sdk.

shootingsyh commented 6 years ago

I think you create wrong object using SANDBOX_AD_ACCOUNT. You need new AdAccount(self::SANDBOX_AD_ACCOUNT) rather than new Campaign(). An ad account is different than a campaign.