When we create audience and add contacts via API, when processing finishes result is always ‘audience too small’. But, when we upload the same data to create new audience directly on Twitter audience manager, data processes correctly and thousands of contacts are matched (audience enters ready state on completion of processing).
This is from audience manager:
Thanks for the quick reply! The following is the requested information:
ad account id: 18ce53z8vuo
timestamp: 2016-12-19 14:58:08
timestamp: 2016-12-19 16:14:31
For the audiences created by direct upload in the UI, the creation timestamp is not in the response when we make a get audiences Api call, so we do not have a way of capturing or storing timstamps from audiences created in Twitter audience manager that get shared back to our app. These are the audiences created via Twitter audience manager UI:
date created: 2016-12-19
date created: 2016-12-20
I am waiting for the audience to either show ‘ready’ or ‘audience too small’ in Twitter audience manager. Processing should have completed at that time, yes? Please let us know if any further information is needed. Any assistance or information you can offer will be greatly appreciated.
Well, 1lz35 was created with the same set of data that 1m40k was generated from and 1m3z3 was the same set of data used for 1m61r, but 1m40k and 1m61r were created in the audience manager UI and the other two via API. So, there should be matches, but I am suspecting a problem with the data we are trying to send to the API (we are still getting a success response, which makes troubleshooting fun).
I was not the original developer of this functionality in our app, and older data has been purged from our test account (so do not readily have ids of previous ‘ready’ audiences, but that part of the code has not changed for a pretty long time, so there should be no difference between previous instances and those reported in this thread).
The code was written to use the raw entries, but I have tried hashing the data as well. The results are the same: ‘audience too small’.
Any further information you can offer will be greatly appreciated.
Agreed since we’re seeing zero matches for 1lz35 and 1m3z3. When did you try using the hashed data? Do you have IDs for those? Have you tried using the scripts found here for hashing the audience files?
The issue might be with the way these are hashed. The hashed contents must be base64-encoded. You could use the base64_encode() function. See this post for more information. Once you create a new audience with this change, please let us know if it resolves the issue.
Thanks for taking the time to provide these details!
The audience has finished processing, and unfortunately the result was the same: audience too small. The audience ID is 1mjfc.
The email addresses were hashed and encoded in PHP as follows:
This same data has produced matches when creating an audience in the audience manager UI. Any information or assistance you can offer will be greatly appreciated.
The base64 encoding in the linked post, above, is for the oauth_body_hash. Sorry about the confusion on that one.
So, the hashing of the entries in the audience file is likely correct. (You can confirm by seeing whether the results of using the hash() function match the results of using one of the these scripts.)
The issue, then, must be with the TON API. Have you tried making a GET request on the returned location header value to see if what you get is what you expect? Note that the hashed data should be sent as the raw post body in the request.
In the meantime, we’ll keep digging on our end. You can also checkout the PHP SDK.
* Success, in this case, isn’t judged by the response code. Rather, we’ve verified that the entries in the audience file are matched with active Twitter users and that the audience shows a “READY” status—that is, "targetable": true.
I’ve been trying to test a subsequent get call to the returned upload location, but keep getting auth required message (which I’m sure is a problem with oauth header; still working that out), but have another question as well: when you say ‘Note that the hashed data should be sent as the raw post body in the request’, that is for the post for uploading the file, not the subsequent get call you recommended, right? We are using curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata) before curl executes the upload to set the hashed data as the post body and do receive a 201 response when the file is uploaded. Any information you can offer will be greatly appreciated.
I was able to sort out the headers. The GET call to the location returned by the TON upload Api call is returning a 200 OK response (curl output below). From this perspective, it appears the TON upload is successful. I have also validated the hashed values in the uploaded file match what is produced by the sample scripts in the twitterdev/ads-platform-tools package on github (from link above). Any further assistance, suggestion, or information you can offer will be greatly appreciated.
If, instead, the response contains newline characters, it’s not correct.
# indicates that the data was not sent correctly
Uploading the audience list
Let’s say we’re just trying to send three hashed entities.
In the request
# incorrectly sends data
$ twurl -X POST -H ton.twitter.com "/1.1/ton/bucket/ta_partner" --header "Content-Type: text/plain" --header "X-TON-Expires: Sat, 14 Jan 2017 06:01:00 GMT" -d "c2bcd645a4baf0db743103c72231b1424b7601664d8ce44cacc614549f822a41\n17fbc61536f4a0169924772b3d7eb83691978d83e3c2480e669e3b29e8749961\ne32f5b173a82318a67a3bd6a5932109dacdc43b4b97614c73f46abab86f80873\n"
This request mirrors the one in the Python example, above. The file data that we’re sending in that example includes the newline characters.
However, while this is a perfectly reasonable way to construct the request at the command line, the data will not be sent correctly (when using bash). The reason is that, “A Posix standard shell does not interpret C escapes.”
So, it appears at some point a third-party package our app uses changed default behavior to enclose fields in a csv file with double quotes. After correcting this, I was able to create audience, add contacts from an uploaded file, and have the audience enter ready state and show the expected number of matches upon completion of processing. Thanks for all your help!