Add CLI script to fetch active Meta Ads insights for campaigns, adsets, and ads
- Implemented a new PHP script to retrieve insights for the last N days (default 30). - Supports command-line options for token, account ID, days, API version, and output file. - Fetches data at campaign, adset, and ad levels, with filtering for active statuses. - Handles JSON output and optional file saving, including directory creation if necessary. - Includes error handling for cURL requests and JSON responses.
This commit is contained in:
@@ -1733,11 +1733,16 @@ function load_campaigns_for_client( restore_campaign_id )
|
||||
var data = JSON.parse( response );
|
||||
var campaigns = Object.entries( data.campaigns || {} );
|
||||
|
||||
campaigns = campaigns.filter( function( pair )
|
||||
{
|
||||
var row = pair[1] || {};
|
||||
var campaign_name = String( row.campaign_name || '' ).toLowerCase().trim();
|
||||
return campaign_name !== '--- konto ---';
|
||||
} );
|
||||
|
||||
campaigns.sort( function( a, b ) {
|
||||
var nameA = String( ( a[1] && a[1].campaign_name ) ? a[1].campaign_name : '' ).toLowerCase();
|
||||
var nameB = String( ( b[1] && b[1].campaign_name ) ? b[1].campaign_name : '' ).toLowerCase();
|
||||
if ( nameA === '--- konto ---' ) return -1;
|
||||
if ( nameB === '--- konto ---' ) return 1;
|
||||
if ( nameA > nameB ) return 1;
|
||||
if ( nameA < nameB ) return -1;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user