Coder Social home page Coder Social logo

Comments (7)

pruno avatar pruno commented on April 24, 2024 1

hi @sandy69,

your script doesn't include the composer autoloader:

// <PROJECT_DIRECTORY> is the dir in which your composer.json is stored
include <PROJECT_DIRECTORY>.'/vendor/autoload.php';

Also take note that 'act_5291585038833333' is not the account name but the id:
Please take a look at this gist: https://gist.github.com/pruno/de102291ddc7539b0583/revisions

If you have any other inherent query, feel free to reply here, i'll will reopen if necessary.

from facebook-php-business-sdk.

ebzlo avatar ebzlo commented on April 24, 2024

Hey @sandy69, have you tried going through the README file and following the steps there?
https://github.com/facebook/facebook-php-ads-sdk/blob/master/README.md

  1. You should install the SDK using composer (in the readme)
  2. You can use the AdAccount object using use FacebookAds\Object\AdAccount; instead of require_once

Here's more about info about composer: https://getcomposer.org/

from facebook-php-business-sdk.

sandy69 avatar sandy69 commented on April 24, 2024

Thank you. I didn't read the README File. Sorry. Let me try and will definitely let you know whether I am successful or not. Again Thanks for your help.

from facebook-php-business-sdk.

ebzlo avatar ebzlo commented on April 24, 2024

No problem. Definitely let me know :)

from facebook-php-business-sdk.

sandy69 avatar sandy69 commented on April 24, 2024

Hello,

I upgraded to php version 5.4.36. Installed the composer and installed the The Facebook Ads API SDK and even after that, when I execute the php script, I get the below error

PHP Fatal error: Class 'FacebookAds\Object\AdAccount' not found in /tmp/vendor/facebook/php-ads-sdk/src/FacebookAds/fb.php on line 3

PHP Code

name = 'act_5291585038833333'; echo $account->name; $params = array( 'date_preset'=>'last_28_days', 'data_columns'=>"['adgroup_id','actions','spend']", ); $stats = $account->getReportsStats(null, $params); foreach($stats as $stat) { echo $stat->impressions; echo $stat->actions; } any information will be highly appreciated

from facebook-php-business-sdk.

sandy69 avatar sandy69 commented on April 24, 2024

Hi,

Thanks for your reply. I made the changes, as you said.

require_once( '/tmp/vendor/autoload.php' );

use FacebookAds\Object\AdAccount;

$account = new AdAccount();
$account->name = 'pinger';
echo $account->name;

Now, I get a different error

PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'An Api instance must be provided as argument or set as instance in the \FacebookAds\Api' in /tmp/vendor/facebook/php-ads-sdk/src/FacebookAds/Object/AbstractCrudObject.php:105
Stack trace:
#0 /tmp/vendor/facebook/php-ads-sdk/src/FacebookAds/Object/AbstractCrudObject.php(68): FacebookAds\Object\AbstractCrudObject::assureApi(NULL)
#1 /tmp/vendor/facebook/php-ads-sdk/src/FacebookAds/fb.php(7): FacebookAds\Object\AbstractCrudObject->__construct()
#2 {main}
thrown in /tmp/vendor/facebook/php-ads-sdk/src/FacebookAds/Object/AbstractCrudObject.php on line 105

Thank you.

From: pruno [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 6:36 AM
To: facebook/facebook-php-ads-sdk
Cc: Sree Iyer
Subject: Re: [facebook-php-ads-sdk] Ads Report Stats Error (#51)

hi @sandy69https://github.com/sandy69,

your script doesn't include the composer autoloader:

// is the dir in which your composer.json is stored
include .'/vendor/autoload.php';

Also take note that 'act_5291585038833333' is not the account name but the id:
Please take a look at this gist: https://gist.github.com/pruno/de102291ddc7539b0583/revisions

If you have any other inherent query, feel free to reply here, i'll will reopen if necessary.


Reply to this email directly or view it on GitHubhttps://github.com//issues/51#issuecomment-69029344.

from facebook-php-business-sdk.

pruno avatar pruno commented on April 24, 2024

hi @sandy69,

you also need to initialize the SDK.

i've updated the gist with the necessary code: https://gist.github.com/pruno/de102291ddc7539b0583/revisions

You can obtain your APP_ID and APP_SECRET from https://developers.facebook.com/apps/
And generate a token from https://developers.facebook.com/tools/explorer/ (remember to select the same app form the select input on top)

Also remember to set your ad_account id:

$account = new AdAccount('act_5291585038833333');

from facebook-php-business-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.