Comments (7)
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.
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
- You should install the SDK using composer (in the readme)
- You can use the
AdAccount
object usinguse FacebookAds\Object\AdAccount;
instead ofrequire_once
Here's more about info about composer: https://getcomposer.org/
from facebook-php-business-sdk.
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.
No problem. Definitely let me know :)
from facebook-php-business-sdk.
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 appreciatedfrom facebook-php-business-sdk.
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.
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)
- Union types are only allowed since php8 HOT 2
- Exception: field 'id' is required Error HOT 3
- شخص ما أخترق حسابي الشخصي
- Normalizer.php strlen() must be of type string Problem
- Facebook Multi-Language Ads
- Syntax error in FB version v16.0.0 HOT 1
- The AdAccountFields enum does not currently implement the ACCOUNT_STATUS field. HOT 1
- Exception thrown without a stack frame in Unknown on line 0 HOT 1
- How to create a AAA advertisements above version 17
- Fix package installation instructions in README file
- Fff HOT 1
- error
- ad creative Url Tracking Params Update HOT 1
- OpenSSL SSL_connect: Connection reset by peer in connection to graph.facebook.com:443 Error HOT 1
- Static singletons used everywhere HOT 3
- Incorrect PHPDoc types HOT 4
- Not able to access Business User Insights for multiple users using the Instagram API. HOT 1
- Where is the TWO_SECOND_CONTINUOUS_VIDEO_VIEWS option? HOT 1
- [README.md] fix typo HOT 3
- I want group id but it says Error: (#100) Missing permissions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facebook-php-business-sdk.