Getting ads accounts via twitter ads php sdk

ads
api

#1

Have just setup hborras twiiter php sdk, how do I fetch the accounts. Am having this error

Fatal error: Uncaught InvalidArgumentException: An Api instance must be provided as argument or set as instance in the \TwitterAds\Api

please help.


#3

Hi @opassky,

This is the code you need:

const CONSUMER_KEY = 'your consumer key';
const CONSUMER_SECRET = 'your consumer secret';
const ACCESS_TOKEN = 'access token';
const ACCESS_TOKEN_SECRET = 'access token secret';
const ACCOUNT_ID = 'account id';


// Create Twitter Ads Api Instance
$api = TwitterAds::init(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

$accounts = $api->getAccounts();

You can see more information here: https://github.com/hborras/twitter-php-ads-sdk