Ads API problems

php

#1

Hi guys,

1) I’m trying to create tailored audiences through API and then populate them also through API with PHP. I’m using Twitter Oauth PHP library by Abraham.

To initialize object, I’m using following keys:

'consumer_key' => 's9eoznsaLE0GZlqJh77HsFemO',
'consumer_secret' => hidden,
'access_token' => '2515659416-J7ZyTPeHVm3NeyFXmxFKyoWXMsuS7czU8ew4KoH',
'access_secret' => hidden

And to fetch all tailored audiences associated with that account, I use following:

->get('accounts/correct_acc_id/tailored_audiences');

where correct_acc_id is indeed correct account id and host is https://ads-api.twitter.com/0/

And response is UNAUTHORIZED_CLIENT_APPLICATION. Went to https://dev.twitter.com/form/ads-api-access-developer and applied. Upon submitting form, page was white and there was no mentioning about how long it usually takes, what should I do next, etc. Page was just blank white. ( As a web dev I find this very unprofessional ) Can anyone answer me those questions?

2) Ok, in the meantime while you are ( hopefully ) checking ( ? ) my app that I submitted, I thought I will try to upload something to your TON API with bucket ta_partner. Guess what? Yeap, again problems.

This is how I tried to upload.

Same object initializing as in 1). then post:

POST /1.1/ton/bucket/ta_partner.json HTTP/1.1
Host: ton.twitter.com
User-Agent: TwitterOAuth v0.2.0-beta2
Accept: /
Content-Type: text/plain
X-TON-Expires: Thu, 03 Dec 2015 09:55:33 GMT
Content-Length: 294

and as POST in BODY there are all required parameters:

data=aa%40aa.com&oauth_consumer_key=xxx&oauth_nonce=xxxx&oauth_signature=xxxxx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=xxxxxx&oauth_token=zzzzz&oauth_version=1.0

I didn’t find nowhere where should I add those signatures, required keys, etc. Is it OK if they are in the body or should ( must? ) they be in the HEADER as Authorization:?

Response for above is:

* upload completely sent off: 294 out of 294 bytes
< HTTP/1.1 403 Forbidden
< content-length: 0
< date: Thu, 26 Nov 2015 09:55:33 GMT
< server: tsa_b
< set-cookie: guest_id=guest_id; Domain=.twitter.com; Path=/; Expires=Sat, 25-Nov-2017 09:55:33 UTC
< strict-transport-security: max-age=631138519
< x-connection-hash: some_hash
< x-content-type-options: nosniff
< x-response-time: 3
< x-tsa-request-body-time: 1
< 
* Connection #0 to host ton.twitter.com left intact

Is it because I must set Authorization header or there is another issue?

Really looking forward to any answers/comments, because I recently did exactly same thing ( create and then populated custom audiences through API ) for other social media website and I didn’t encounter absolutely any problems.

Thanks.


#2

@jchoi @jillblaz


#3

Hi @divireizdivi ,

Abraham Twitteroauth SDK is designed only to consume Twitter Social API, not ADS.

The first version of my App also used it and I made a fork on github with a small change to enable Abraham SDK to consume Ads API, If you’d like to take a look:

The change was only at:
https://github.com/BCJTI/twitteroauth/blob/master/src/TwitterOAuth.php lines 23, 303, 316 and 330!

Good luck and best regards!

Felipe


#4

Hi,

Thanks for the help, but I figured from the code that it is designed for only social API and of course I changed host and version to match those in ads API. So my API calls should be correct. The problems are in responses I receive - as I understood, I need to wait for APP to be whitelisted, but I can’t see anywhere where it would say approximately how long it usually takes or something like that.

4 days are past and still nothing… c’mon Twitter, you can do better!


#5

Tested with OAuth signature generator:

Result that OAuth signature gave me:

curl --get 'https://ads-api.twitter.com/0/accounts/18ce53xcguj/tailored_audiences' --header 'Authorization: OAuth oauth_consumer_key="s9eoznsaLE0GZlqJh77HsFemO", oauth_nonce="xxx", oauth_signature="xxx", oauth_signature_method="HMAC-SHA1", oauth_timestamp="xxx", oauth_token="xxx", oauth_version="1.0"' --verbose

where xxx are correct values from OAuth signature generator.

Response still the same:

`< HTTP/1.1 403 Forbidden
< content-disposition: attachment; filename=json.json
< content-length: 167
< content-type: application/json;charset=utf-8
< date: Wed, 02 Dec 2015 09:49:08 GMT
< server: tsa_o
< set-cookie: guest_id=v1%3A144904974839038009; Domain=.twitter.com; Path=/; Expires=Fri, 01-Dec-2017 09:49:08 UTC
< strict-transport-security: max-age=631138519
< x-access-level: read-write
< x-connection-hash: 740b1f34927a1f612726a23976d53b8e
< x-content-type-options: nosniff
< x-frame-options: SAMEORIGIN
< x-rate-limit-limit: 2000
< x-rate-limit-remaining: 1998
< x-rate-limit-reset: 1449050600
< x-response-time: 131
< x-runtime: 0.001113
< x-transaction: 43ddf9a6e4e183a4
< x-xss-protection: 1; mode=block
<

  • Connection #0 to host ads-api.twitter.com left intact
    {“errors”:[{“code”:“UNAUTHORIZED_CLIENT_APPLICATION”,“message”:“The client application making this request does not have access to this API”}],“request”:{“params”:{}}}`

#6

@divireizdivi What is your App ID? You can find this in the URL of the app’s page on apps.twitter.com. It should be 7-8 digits.


#7

Hi,

App ID is 6312199


#8

Any updates on this? I’ve just tried new oauth requests, but still getting same response. 3+ months have passed…


#9

Hi - this app does not have Ads API access. Are you looking to build audiences for ad targeting? If so, apply for API access here: https://dev.twitter.com/form/ads-api-access-developer


#10

I have already applied on the 15th of Nov 2015. I have written it in the topic description:

And response is UNAUTHORIZED_CLIENT_APPLICATION. Went to https://dev.twitter.com/form/ads-api-access-developer and applied. Upon submitting form, page was white and there was no mentioning about how long it usually takes, what should I do next, etc. Page was just blank white

Can you please check my data? 7 months are passed…


#11

Hi @divireizdivi,

Confirming that you should of been whitelisted on 7/11.
Carmen


#12