Trouble Accessing Data on Ads API (using PHP)

ads
php
api

#1

I’ve been trying to access data on a particular account that I have access to via the ADs API but keep getting either “UNAUTHORIZED ACCESS” or “ACTION_NOT_ALLOWED” error messages when I try to make certain calls.

Calls That I’ve Tried so far:
/accounts/ == Works as expected.
/accounts/XXXXXX/promoted_tweets == ACTION_NOT_ALLOWED
/stats/jobs/accounts/XXXXXX?entity=account == UNAUTHORIZED_ACCESS
/stats/accounts/XXXXXX?entity=ORGANIC_TWEET == UNAUTHORIZED_ACCESS

I’m 99.9% sure I have the coding and auth settings correct because it’s working fine with this call:
https://ads-api.twitter.com/4/accounts/
…but not on any of the others listed.

The consumer key, secret, account id, etc are def all correct in the code. The only thing I can think of that I haven’t tried is that the access level of the authenticated user to get this info needs to be higher than an Analyst? Or do we need to regenerate all the keys and secrets again?

Just a little extra background:

  • I see the correct account id that I’m trying to access in the response from the “/accounts/” call.
  • The app information we’re using is from an approved one (for ads api) and our level of access is an Analyst.

Attached are screenshots of the response messages I’m seeing:
adsapi1


#2

Hi @thomasdintrone, as you suspected you will need higher level of access for this account to be able to use the API to pull this data. Some info at the link below:

https://developer.twitter.com/en/docs/ads/general/guides/obtaining-ads-account-access.html


#3

@joncipriano, thanks for the quick response. We upgraded our account and I’m now seeing new information but certain other calls I’m still getting the UNAUTHORIZED_ACCESS Error. Any thoughts?

Example Call:
adsapi4


#4

Hi @thomasdintrone ,

I see you masked your Ads account ID on that screen shot. Providing your Ads account ID here (publicly) is totally safe. Could you tell us your Ads account ID so that we can get more insight for this issue?

Best,
Shohei


#5

Hi @jrsyo, ah ok I wasn’t sure so thought it was a safe bet to leave it out. The account ID is aefe1


#6

@thomasdintrone

Thanks. Please check this post:

Are you encoding your OAuth header strings?
https://developer.twitter.com/en/docs/basics/authentication/guides/percent-encoding-parameters
https://developer.twitter.com/en/docs/basics/authentication/guides/authorizing-a-request

Best,
Shohei