Creating a Tailored Audience using Java Ads API SDK


#1

Hi All,

I am not able to implement the Tailored Audience Creation using the java ads api sdk. Could you please help me in the right direction.

I have all the 4 tokens and account id, but when i am creating my own class and referncing the TailoredAudienceImpl.java , i am not getting some of the instances.

I simply need to create a tailored audience and upload data file using java ads api sdk.

Regards


#2

cc: @abhishek_pyro


#3

Please help me, it’s urgent.

Thanks in advance.


#4

Hey, what version are you using of Twitter4j-ads?


#5

4.0.4

I have implemented it . I am using the Tailored Audience Implementation.
I am calling the createTailoredAudience method with accountID,Audience Name and Tailored Audience Type EMAIL. It is returning an object of BaseAdsResponse of TailoredAudience.

I can see that the Tailored Audience is getting created but it is hsowing processing since long time.

When i print the object of BaseAdsResponse, it shows null.

Please help


#6

@abhishek_pyro Could you please help me urgently with the steps to create tailored audience.


#7

@abhishek_pyro

I am using this.

BaseAdsResponse ta = audienceApi.createTailoredAudience(accountID,“Test21”, TailoredAudienceDataType.EMAIL);

but ta object gives null.

Thanks in advance for the help.


#8

Hi @kingams16 this function corresponds to https://dev.twitter.com/ads/reference/post/accounts/%3Aaccount_id/tailored_audiences which creates the audience shell and then you add file to it later with the tailored_audience_changes endpoint.

I’m not sure why the object is returning null but I just ran some code calling the same line of code and I now see the tailored_audience in my account hitting it with twurl. I would recommend using the SDK and twurl in parallel as it will be easier for you to double check that things are being created correctly.


#9

could you please send me some sample line of code that will help me for creating tailored audience using java sdk.

Regards and thanks


#10
    TwitterAds twitterAdsInstance = getTwitterAdsInstance();
    TwitterAdsAudienceApi audienceApi = twitterAdsInstance.getTailoredAudienceApi();
    try {
        BaseAdsResponse ta = audienceApi.createTailoredAudience("<insert your account ID here>", "Test", TailoredAudienceDataType.EMAIL);
    } catch (TwitterException e) {
        System.err.println(e.getErrorMessage());
    }

This is with the 1.1 version of JAR, I would recommend starting with the samples from Examples and play around with those. The team is aware of some compilation issues with code as it is on GitHub - thanks for working around those in the meantime.


#11

@JBabichJapan , @abhishek_pyro

The audience is getting created in the twitter ads account. But the response object is still displaying null. Could you please help.

Regards


#12

@JBabichJapan Please help me why the
TwitterTonUploadResponse upR = audienceApi.uploadTailoredAudience(file);
is returning null even when i can see the audience in the twitter ads account.

Please help me urgently since one of my important work is stucked.

Regards and thanks in advance for help.


#13

Hi @JBabichJapan and team,

Could you please clear my confusion.

Let’s say the data file have 3 columns let say name,phone , email.
Column 1 Column 2 Column 3
Name Phone Email

Then if i upload it through sdk code and audience type is EMAIL (TailoredAudienceDataType.EMAIL) , then the uploaded audience will have email or email along with other details as well.

Help me with the BaseAdsResponse ta = audienceApi.createTailoredAudience("", “Test”, TailoredAudienceDataType.EMAIL); as well i am stucked.

Please help.


#14

Hi @JBabichJapan , @abhishek_pyro Please help me with this issue.

Also could you please let me know when i am creating the tailored audience from java code and uploading the file , do i need to write any line of code for hashing the file.

It will be better if you provide code for the complete functionality of creating tailored audience and uploading the data file including hashing.

Regards and thanks in advance for help.


#15

Hashing needs to be done before uploading

        return org.apache.commons.codec.digest.DigestUtils.sha256Hex(txt);```

TwitterTonUploadResponse object returning null
#16

A Ton file (file uploaded on Ton) could have only one type of data for one operation.

Please refer the docs, the docs clarify this point in details


#17

Thanks @abhishek_pyro for the details , could you please provide me a complete set of code for example so that i can undertand even better for creating a tailored audience and uploading the data file alngwith hashing.

Thanks a lot in advance for help.


#18

Unfortunately the only sample code readily available are those under https://github.com/sprinklr-inc/twitter4j-ads/tree/master/twitter4j-ads-examples - we are welcome to contributions if you figure it out before someone can add one there.

For the data upload part there are samples available for scripting languages like: https://github.com/twitterdev/ton-upload/blob/master/ton_upload if you just need to upload files programmatically you could script using that with commands like ./ton_upload -m upload -b ta_partner -f ~/my_data.txt but this would simply be a workaround available for you.


#19

@JBabichJapan and @abhishek_pyro and team

Please give me the set of code for hashing the data file before uploading to tailored audience. that will be great.

Thanks


#20

@JBabichJapan , @abhishek_pyro

It will be great if you can help me with the 2-3 lines of code for uploading the data file after hashing to the tailored audience.

thanks