PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 6, 2022

[FIXED] Getting "Invalid parameter" exception on getReportsStats with no reason

 January 06, 2022     facebook, facebook-ads-api, facebook-php-sdk, php, sdk     No comments   

Issue

Can anyone help me with a fast code review?

$fields = array(
    'campaign_id',
    'spend'
);
$params = array(
    'data_columns' => $fields,
    'time_interval' => array(
        'day_start' => array(
            'year' => 2011,
            'month' => 9,
            'day' => 1
        ),
        'day_stop' => array(
            'year' => 2011,
            'month' => 9,
            'day' => 10
        ),
    ),
);
$stats = $adAccount->getReportsStats(array(), $params);

After running this code I am getting:

<b>Fatal error</b>:  Uncaught exception 'FacebookAds\Http\Exception\AuthorizationException' with message 'Invalid parameter' in /home/maciekmp/public_html/face_test/FacebookAds/Http/Exception/RequestException.php:129
fdfd

Solution

I found the following in the facebook api developer docs. Search on "async". If the data you are querying is too old you will have to do an asynchronous call to the graph api. Which is usually the case with the error you received. The current version of the php-sdk does not support passing an async parameter out of the box. Since AdAccount defaults to GET request and async calls to the graph api must be done with POST request, you will need to extend the AdAccount class and create and prepare a request to use the POST method.



Answered By - Rodney
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing