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:
2026-02-20 23:45:36 +01:00
parent 167ced3573
commit b54a9a71b1
34 changed files with 8516 additions and 1676 deletions

View File

@@ -31,10 +31,6 @@
</button>
</div>
</div>
<div class="filter-group filter-group-roas">
<label for="bestseller_min_roas"><i class="fa-solid fa-star"></i> Bestseller min ROAS</label>
<input type="text" id="bestseller_min_roas" name="bestseller_min_roas" class="form-control" placeholder="np. 500" value="" />
</div>
<div class="filter-group filter-group-columns">
<label><i class="fa-solid fa-table-columns"></i> Kolumny</label>
<details class="products-columns-control">
@@ -521,25 +517,6 @@ $( function()
return false;
}
function load_client_bestseller_min_roas( client_id )
{
if ( !client_id )
{
$( '#bestseller_min_roas' ).val( '' );
return;
}
$.ajax({
url: '/products/get_client_bestseller_min_roas/',
type: 'POST',
data: { client_id: client_id },
success: function( response ) {
var data = JSON.parse( response );
$( '#bestseller_min_roas' ).val( data.status == 'ok' ? data.min_roas : '' );
}
});
}
function load_products_campaigns( client_id, selected_campaign_id )
{
var $campaign = $( '#products_campaign_id' );
@@ -1084,7 +1061,6 @@ $( function()
localStorage.removeItem( 'products_ad_group_id' );
update_delete_ad_group_button_state();
load_client_bestseller_min_roas( client_id );
load_products_campaigns( client_id, '' ).done( function() {
load_products_ad_groups( '', '' ).done( function() {
update_delete_ad_group_button_state();
@@ -1189,7 +1165,6 @@ $( function()
$( '#client_id' ).val( savedClient );
}
load_client_bestseller_min_roas( $( '#client_id' ).val() || '' );
load_products_campaigns( $( '#client_id' ).val() || '', savedCampaign ).done( function() {
var selected_campaign_id = $( '#products_campaign_id' ).val() || '';
load_products_ad_groups( selected_campaign_id, savedAdGroup ).done( function() {
@@ -1631,25 +1606,6 @@ $( function()
});
});
// Zapis min ROAS klienta (bestseller)
$( 'body' ).on( 'blur', '#bestseller_min_roas', function()
{
var min_roas = $( this ).val();
var client_id = $( '#client_id' ).val();
$.ajax({
url: '/products/save_client_bestseller_min_roas/',
type: 'POST',
data: { client_id: client_id, min_roas: min_roas },
success: function( response ) {
data = JSON.parse( response );
if ( data.status == 'ok' ) {
$.alert({ title: 'Zapisano', content: 'Minimalny ROAS bestsellerów został zapisany.', type: 'green', autoClose: 'ok|2000', buttons: { ok: function() {} } });
}
}
});
});
// Checkbox: zaznacz/odznacz wszystkie
function updateSelectedCount() {
var count = $( '.product-checkbox:checked' ).length;