New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getInsightsAsync() and getInsights() return different results #169
Comments
Hello @benjamin-schaefer, thx for reaching out. Can you help with more details by sharing a log using the |
Hello @duliomatos, |
@benjamin-schaefer Yeah, for the result data, can you try to replace the real values? At least for the calls you can automatically hide sensitive data using the example logger :-) // Hide target ids and tokens
$logger->setShowSensitiveData(false); |
@duliomatos unfortunately, using the logger as in the example, causes a notice and an error: Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in /home/benjamin/lampstack-5.5.30-1/apache2/htdocs/vendor/facebook/php-ads-sdk/src/FacebookAds/Logger/CurlLogger.php on line 72 Fatal error: Call to undefined method FacebookAds\Logger\CurlLogger::setEscapeLevels() in /home/benjamin/lampstack-5.5.30-1/apache2/htdocs/getReportings.php on line 38 Here you can see my debug data for the sync insights object (all real number values were replaced by 0): FacebookAds\Object\Insights Object ( [data:protected] => Array ( [account_id] => [account_name] => [action_values] => [actions] => Array ( [0] => Array ( [action_type] => comment [value] => 0 ) [1] => Array ( [action_type] => like [value] => 0 ) [2] => Array ( [action_type] => link_click [value] => 0 ) [3] => Array ( [action_type] => post [value] => 0 ) [4] => Array ( [action_type] => post_like [value] => 0 ) [5] => Array ( [action_type] => page_engagement [value] => 0 ) [6] => Array ( [action_type] => post_engagement [value] => 0 ) ) [actions_per_impression] => [ad_id] => [ad_name] => [adset_id] => [adset_name] => [call_to_action_clicks] => 0 [campaign_id] => 0 [campaign_name] => Campaign 1 [cost_per_action_type] => Array ( [0] => Array ( [action_type] => comment [value] => 0 ) [1] => Array ( [action_type] => like [value] => 0 ) [2] => Array ( [action_type] => link_click [value] => 0 ) [3] => Array ( [action_type] => post [value] => 0 ) [4] => Array ( [action_type] => post_like [value] => 0 ) [5] => Array ( [action_type] => page_engagement [value] => 0 ) [6] => Array ( [action_type] => post_engagement [value] => 0 ) ) [cost_per_total_action] => [cost_per_unique_click] => [cost_per_inline_link_click] => [cost_per_inline_post_engagement] => [cpm] => 0 [cpp] => 0 [ctr] => 0 [date_start] => 2000-01-01 [date_stop] => 2016-12-24 [frequency] => 0 [impressions] => 0 [inline_link_clicks] => 0 [inline_post_engagement] => [product_id] => [reach] => 0 [relevance_score] => [social_clicks] => 0 [social_impressions] => 0 [social_reach] => [spend] => 0 [total_action_value] => 0 [total_actions] => 0 [total_unique_actions] => [unique_clicks] => 0 [unique_ctr] => [unique_social_clicks] => 0 [video_avg_pct_watched_actions] => [video_avg_sec_watched_actions] => [video_complete_watched_actions] => [video_p100_watched_actions] => [video_p25_watched_actions] => [video_p50_watched_actions] => [video_p75_watched_actions] => [video_p95_watched_actions] => [website_ctr] => ) ) And here the async insights object : FacebookAds\Object\Insights Object ( [data:protected] => Array ( [account_id] => [account_name] => [action_values] => [actions] => Array ( [0] => Array ( [action_type] => comment [value] => 0 ) [1] => Array ( [action_type] => like [value] => 0 ) [2] => Array ( [action_type] => link_click [value] => 0 ) [3] => Array ( [action_type] => post [value] => 0 ) [4] => Array ( [action_type] => post_like [value] => 0 ) [5] => Array ( [action_type] => page_engagement [value] => 0 ) [6] => Array ( [action_type] => post_engagement [value] => 0 ) ) [actions_per_impression] => [ad_id] => [ad_name] => [adset_id] => [adset_name] => [call_to_action_clicks] => 0 [campaign_id] => 0 [campaign_name] => [cost_per_action_type] => Array ( [0] => Array ( [action_type] => comment [value] => 0 ) [1] => Array ( [action_type] => like [value] => 0 ) [2] => Array ( [action_type] => link_click [value] => 0 ) [3] => Array ( [action_type] => post [value] => 0 ) [4] => Array ( [action_type] => post_like [value] => 0 ) [5] => Array ( [action_type] => page_engagement [value] => 0 ) [6] => Array ( [action_type] => post_engagement [value] => 0 ) ) [cost_per_total_action] => 0 [cost_per_unique_click] => 0 [cost_per_inline_link_click] => 0 [cost_per_inline_post_engagement] => 0 [cpm] => 0 [cpp] => 0 [ctr] => 0 [date_start] => 2000-01-01 [date_stop] => 2016-12-24 [frequency] => 0 [impressions] => 0 [inline_link_clicks] => 0 [inline_post_engagement] => 0 [product_id] => [reach] => 0 [relevance_score] => [social_clicks] => 0 [social_impressions] => 0 [social_reach] => 0 [spend] => 0 [total_action_value] => 0 [total_actions] => 0 [total_unique_actions] => 0 [unique_clicks] => 0 [unique_ctr] => 0 [unique_social_clicks] => 0 [video_avg_pct_watched_actions] => [video_avg_sec_watched_actions] => [video_complete_watched_actions] => [video_p100_watched_actions] => [video_p25_watched_actions] => [video_p50_watched_actions] => [video_p75_watched_actions] => [video_p95_watched_actions] => [website_ctr] => Array ( [0] => Array ( [action_type] => link_click [value] => 0 ) ) [buying_type] => AUCTION [unique_actions] => Array ( [0] => Array ( [action_type] => comment [value] => 0 ) [1] => Array ( [action_type] => like [value] => 0 ) [2] => Array ( [action_type] => link_click [value] => 0 ) [3] => Array ( [action_type] => post [value] => 0 ) [4] => Array ( [action_type] => post_like [value] => 0 ) [5] => Array ( [action_type] => page_engagement [value] => 0 ) [6] => Array ( [action_type] => post_engagement [value] => 0 ) ) [unique_impressions] => 0 [unique_social_impressions] => 0 [deeplink_clicks] => 0 [app_store_clicks] => 0 [website_clicks] => 0 [unique_link_clicks_ctr] => 0 [cost_per_unique_action_type] => Array ( [0] => Array ( [action_type] => comment [value] => 0 ) [1] => Array ( [action_type] => like [value] => 0 ) [2] => Array ( [action_type] => link_click [value] => 0 ) [3] => Array ( [action_type] => post [value] => 0 ) [4] => Array ( [action_type] => post_like [value] => 0 ) [5] => Array ( [action_type] => page_engagement [value] => 0 ) [6] => Array ( [action_type] => post_engagement [value] => 0 ) ) [estimated_ad_recallers] => 0 [estimated_ad_recallers_lower_bound] => 0 [estimated_ad_recallers_upper_bound] => 0 [estimated_ad_recall_rate] => 0 [estimated_ad_recall_rate_lower_bound] => 0 [estimated_ad_recall_rate_upper_bound] => 0 [cost_per_estimated_ad_recallers] => 0 ) ) |
@benjamin-schaefer sorry, the example file is a little dated, just remove this line from the example, as this function does not exist: $logger->setEscapeLevels(1); |
This one also won't work, my bad: |
@duliomatos okay, now I get the same error for "setShowSensitiveData()".... when I also leave out this command, the export says: FacebookAds\Logger\CurlLogger Object ( [handle:protected] => STDOUT ) So this is not what I want... how can I use it to log my insight request? |
A better example would be: // Run this before your request
use FacebookAds\Logger\CurlLogger;
$logger = new CurlLogger();
// OR something like this if you are not running php on the command line
// $logger = new CurlLogger(fopen('curl.log','w'));
Api::instance()->setLogger($logger);
// Your request... |
Okay, thank you - the fopen was missing. Sorry, I'm just new on php. here are my curl logs, with zeroed IDs: curl -G \ -d 'time_range={"since":"2011-01-01","until":"2016-02-06"}' \ -d 'level=campaign' \ -d 'fields=campaign_name,campaign_id,actions,reach,frequency,impressions,social_impressions,unique_clicks,spend,total_actions,total_action_value,cost_per_action_type,cpm,cpp,ctr,call_to_action_clicks,inline_link_clicks,social_clicks,unique_social_clicks' \ -d 'access_token=TOKEN' \ -d 'appsecret_proof=PROOF' \ https://graph.facebook.com/v2.5/0000000000057/insights async: curl \ -F 'time_range={"since":"2011-01-01","until":"2016-02-06"}' \ -F 'level=campaign' \ -F 'access_token=TOKEN' \ -F 'appsecret_proof=PROOF' \ https://graph.facebook.com/v2.5/0000000000057/insights I hope that helps! |
PS: I obscured access_token and appsecret_proof in your comment as well |
Thanks. Can you work with these curl data? |
@benjamin-schaefer, it surely helps! |
I'm closing as duplicate of #157, which was fixed recently. LMK of anything else @benjamin-schaefer. |
For a given campaign, I want to return the insights. For this, I used same $fields and $params arrays for getInsights() und getInsightsAsync():
Here's the code for getInsights():
This returned NOT EMPTY values for
But it also returned EMPTY values for
Here my code for the asynchronous call:
This returns additionaly the following NOT EMPTY fields:
But, here the following field is empty:
Am I doing something wrong or is there an issue?
Additionally, how can I get values for Delivery, Results, Cost and cpc? Is this possible by the ads sdk? In business ads manager, I can get these values in a table.
Regards,
Benjamin Schäfer
The text was updated successfully, but these errors were encountered: