Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
304 views
in Technique[技术] by (71.8m points)

Using Twitter Ads API to create a scheduled tweet

I have hard time organize API calls to Twitter Ads API in order to create a simple sponsored tweet and I would love to get someone's help on that problem.

I'm using the following sequence of API calls and probably there is something I am missing:

1) I have the ad_account set as a variable

2) getting funding instruments for the account:

GET https://ads-api.twitter.com/8/accounts/:account_id/funding_instruments

-- result --

{
    ...
    id: '11uze5', <---- THIS IS THE ID I'M STORING 
    entity_status: 'ACTIVE',
    account_id: '18ce55bxgcw',
    ...
}

3) creating a campaign:

POST https://ads-api.twitter.com/8/accounts/:account_id/campaigns

parameters:

{
    funding_instrument_id: THE ID I"M GETTING FROM THE PREVIOUS CALL
    name: "New Campaign 1",
    start_time: "2021-07-05T00:00:00Z",
    daily_budget_amount_local_micro: "140000000",
    entity_status: "PAUSED",
}

-- result ---

{
    ...
    name: 'New Campaign 1',
    id: 'f0ulq', <--- THIS IS THE ID I'M USING AS CAMPAIGN ID
    ...

}

4) creating a line item into the newly created camapign:

POST https://ads-api.twitter.com/8/accounts/:account_id/line_items

parameters:

{
    campaign_id: THE ID I"M GETTING FROM THE PREVIOUS CALL,
    objective: "WEBSITE_CLICKS",
    placements: "ALL_ON_TWITTER",
    product_type: "PROMOTED_TWEETS",
    entity_status: "PAUSED",
    bid_amount_local_micro: "3210000",
}

-- result --

{
    ...
    advertiser_user_id: 1326770328459227100
    name: 'Untitled'
    id: 'iocme', <-- THE ID I'M USING AS LINE ITEM ID
}

5) uploading a file to be used as an image on the sponsored tweet (using media_category in order to get media_key parameter from the result) -- result --

{
    media_id: 1354065257501765600,
    media_id_string: '1354065257501765634',
    media_key: '3_1354065257501765634',
    size: 127727,
    expires_after_secs: 86400,
    image: { image_type: 'image/jpeg', w: 960, h: 637 },
}

6) get authenticated users for the account GET https://ads-api.twitter.com/8/accounts/:account_id/authenticated_user_access

-- result --

{
    user_id: 1326770328459227100, <-- THIS IS THE USER ID I'M USING WHEN CREATING THE TWEET
    permissions: [ 'ACCOUNT_ADMIN', 'TWEET_COMPOSER' ]
}

7) creating scheduled tweet POST https://ads-api.twitter.com/8/accounts/:account_id/scheduled_tweets

parameters:

{
    scheduled_at: "2021-02-01T23:59:00Z",
    text: "Scheduled tweet!",
    media_keys: MEDIA_KEY PARAMETER FROM THE UPLOADED MEDIA,
    as_user_id: 1326770328459227100 (THE USER ID FROM THE authenticated user's list)
}

ERROR FROM TWITTER:

    code: 'NOT_FOUND',
    message: 'Promotable User 1326770328459227100 was not found for Account 18ce55bxgcw'

So, what I'm doing wrong?

Thanks a lot in advance,

question from:https://stackoverflow.com/questions/65903566/using-twitter-ads-api-to-create-a-scheduled-tweet

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...