I want transform this Facebook Graph API request:
act_xyz/ads?fields=insights.date_preset(yesterday){ad_name,adset_name,campaign_name,account_name,account_id,impressions,inline_link_clicks,spend,ad_id},adcreatives{object_story_spec}
to use Facebook Ads PHP SDK. Now I have this code:
$account = new AdAccount('act_xyz');
$fields = array(
InsightsFields::AD_NAME,
InsightsFields::ADSET_NAME,
InsightsFields::CAMPAIGN_NAME,
InsightsFields::ACCOUNT_NAME,
InsightsFields::ACCOUNT_ID,
InsightsFields::IMPRESSIONS,
InsightsFields::INLINE_LINK_CLICKS,
InsightsFields::SPEND,
InsightsFields::AD_ID
);
$params = array(
'date_preset' => InsightsPresets::YESTERDAY
);
$account->getInsights($fields, $params);
[...]
$fields = array(
AdCreativeFields::OBJECT_STORY_SPEC
);
$account->getAdCreatives($fields);
I can get all data separately, but I want obtain AdCreatives and Insights for each Ad on my AdAccount like Graph API does. Thanks.