Ads analytics api return error message "FORBIDDEN"



Hope you are doing well.

I need your help on the following issue.

I downloaded the hborras php sdk from

The problem is, the script twitter-php-ads-sdk-master\examples\analytics.php gave me proper results yesterday but today gave me error message “FORBIDDEN”.

I am a bit confused why the same script gave me different result yesteray and today?

Any idea on this?




Hi @XP01955795,

It seems as though the version number was not updated from 1.0 to 2.0 on Request.php. This has now been updated and if you pull down again it should work!


Hey Brent,

Thank you very much for investigating on this.

The confusing thing is, the same script returned proper result but the next day broken.

Also, as suggested, I redownload the newest lib, regenerate the four keys(token) and run analytics.php again, I got “NOT_AUTHORIZED” error message.

Can u pls let me know is anything wrong on my side? Is it app access privilege issue?

Any questions please let me know. Thanks.



Hi @XP01955795,

Can you try using twurl with a simple command like the following then paste the response here? Also can please give your app ID so I can review access.

twurl -t -H "/2/accounts/18ce54d4x5t/authenticated_user_access" | jq


Hi Brent,

I noticed twurl is built on Ruby which I haven’t used before. Is there other method we can verify? Also, the app id is 14506168

Thanks again!



Hi @XP01955795,

Installing twurl is very simple and dependencies should install using the instructions I sent over before. This is the easiest way to see that you’re authenticated correctly. Which is what I believe is the problem but need more details to debug. I’ve added “-t” to the example twurl call I sent before which gives us more information for troubleshooting.


Hey Brent,

I installed twurl and run the command u sent, also, since 18ce54d4x5t is not our ad account property, I run another command against our own ad account id,
the two commands:
twurl -t -H “/2/accounts/18ce54d4x5t/authenticated_user_access” | jq

twurl -t -H “/2/accounts/18ce54hy82g/authenticated_user_access” | jq

The two screenshots are:

Many thanks!



Hi @XP01955795,

From the looks of your response, your user ID is an account admin for acct ID 18ce54hy82g. Can you attempt the analytics request you were trying to make before with the SDK, instead using twurl?

Sync analytics documentation with examples -