Closed mohandas614 closed 6 years ago
Hi @mohandas614
Could you sare also the piece of code you're executing?
Thanks!
@hborras Thanks for replay.
Here is my code ` // Create Twitter Ads Api Instance $api = TwitterAds::init(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$accounts = $api->getAccounts(); // load up the account instance, campaign and line item $account = new Account(ACCOUNT_ID); $account->read(); $campaigns = $account->getCampaigns('', [TwitterAds\Fields\CampaignFields::COUNT => 10]);`
It looks like your credentials have expired.
Have you tried to regenerate a new ones?
https://apps.twitter.com/app/YOUR_APP_ID/keys
Here you can regenerate them and try it again
@hborras Yes, I have regenerated the credentials and applied the same. But still I am getting this error. Even if I give wrong credentials also getting the same error.
Thanks!
HI @hborras Can you please do me a favour. Can you please check with your credentials if you have. So I can confirm from my end something wrong or not.
Hi @mohandas614 Just tested with the code inside the "analytics.php" with right credentials and it works good.
Did you apply to the TWITTER ADS API in order to get access?
Are you using the right credentials (i mean, maybe you're using ones from other Twitter App)
@hborras Yes, I applied to the TWITTER ADS API access. And I got mail with below content
Congratulations! Your application has been approved for the Twitter Ads API program and your organization has been granted a Developer license. ADS API - DEVELOPER ACCESS The Developer license provides access to all Ads API endpoints to develop your tool to completion. Developer-level partners are limited to five OAuth tokens and prohibited from exposing any Ads API functionality to external advertisers.
I double checked and using related Twitter App credentials only.
FYI: I checked with "pmg/twitterads" package also and getting the same error.
Mmmm,
It looks strange.
Do you have the last version of the lib? I mean, they have destroyed TwitterADSv1, with the last version of the lib you will get the v2.
Could you try something?
Install twurl: https://github.com/twitter/twurl
% twurl authorize --consumer-key key \ --consumer-secret secret
After this try:
twurl -H ads-api.twitter.com /2/accounts/
And paste the response
@hborras
Thank you very much for above reply. I have upgrade to latest version and its working now.
Thank you very much for your support and you saved my time.
Thanks!
Always I am getting below error even all credentials are correct and have enough permissions. My account is "Account Administrator" role.
Fatal error: Uncaught exception 'Hborras\TwitterAdsSDK\TwitterAds\Errors\Forbidden' with message 'FORBIDDEN' in /var/www/html/twitter_ads/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php:470 Stack trace: #0 /var/www/html/twitter_ads/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php(447): Hborras\TwitterAdsSDK\TwitterAds->manageErrors(Object(stdClass)) #1 /var/www/html/twitter_ads/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php(252): Hborras\TwitterAdsSDK\TwitterAds->http('GET', 'https://ads-api...', 'accounts', Array) #2 /var/www/html/twitter_ads/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds/Resource.php(66): Hborras\TwitterAdsSDK\TwitterAds->get('accounts', Array) #3 /var/www/html/twitter_ads/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php(119): Hborras\TwitterAdsSDK\TwitterAds\Resource->all() #4 /var/www/html/twitter_ads/analytics.php(20): Hborras\TwitterAdsSDK\TwitterAds->getAccounts() #5 {main} thrown in /var/www/html/twitter_ads/vendor/hborras/twitter-php-ads-sdk/src/TwitterAds.php on line 470
Please assist me what I am missing. Initially it worked for some days and suddenly it is throwing this error always.
Thanks in advance.