Image for website card


#1

I’m trying to create website cards and ran into a problem regarding images / creatives. I think the required set of steps is the following:

  1. Upload image file using https://dev.twitter.com/rest/reference/post/media/upload to upload an image (this does not seem to have a sandboxed version)
  2. Use “media_id” returned from above to create an account media using https://dev.twitter.com/ads/reference/post/accounts/account_id/account_media
  3. Use “id” returned from above to create website card using https://dev.twitter.com/ads/reference/post/accounts/account_id/cards/website

Since I want to create a Website Card, my w/h image ratio must be 2.5. “creative_type” param from point 2 above takes me to the “Creative Types” on https://dev.twitter.com/ads/basics/enums — here none of the options match the 2.5 image ratio. How does one create a website card with those dimensions there?

Some other inconsistencies / annoying things I found:

https://dev.twitter.com/ads/creative looks empty at first glance. In this forum I found https://dev.twitter.com/ads/creative/revenue-cards which is where I got the image dimensions for website cards. This page starts out with “The Ads API supports a number of creatives to be used in your campaigns. The following specs apply to the app_download, image_app_download, image_conversation, lead_gen, website card endpoints.” but then the title is “Revenue Cards”, which doesn’t really make sense.


#2

@CMP: Please see this post as well as the linked threads within it for more information.


#3

@juanshishido

I don’t think the links answer the questions I asked.

  • From the post you linked:

The procedure is the same as the previous one except that in the course of the creation of the campaign we create a tweet with the following endpoint
ads/reference/post/accounts/%3Aaccountid/tweet_

In this Endpoint we have the possibility to add images to the tweet which we have also implemented with
ads/reference/post/accounts/%3Aaccountid/account_media_

The problem with this type of images is that we can only use 2 different and very specific sizes, which are:

BANNER: 320x50
INTERSTITIAL: 320 x 480

This is related to the question I raised here, but I don’t see it answered anywhere on the threads linked. My specific questions was:

Since I want to create a Website Card, my w/h image ratio must be 2.5. “creative_type” param from point 2 above takes me to the “Creative Types” on https://dev.twitter.com/ads/basics/enums — here none of the options match the 2.5 image ratio. How does one create a website card with those dimensions there? Am I missing something?

  • I tried executing the steps you mentioned here. This is what I get:

    ~ ❯❯❯ twurl -X POST -H upload.twitter.com “/1.1/media/upload.json” -f ~/Downloads/f4-good-dimensions-800x320.PNG -F media | jq
    {
    “media_id”: 800916839568121900,
    “media_id_string”: “800916839568121857”,
    “size”: 107022,
    “expires_after_secs”: 86400,
    “image”: {
    “image_type”: “image/png”,
    “w”: 800,
    “h”: 320
    }
    }
    ~ ❯❯❯ twurl -H upload.twitter.com “/1.1/media/upload.json?command=STATUS&media_id=800916839568121900” | jq
    {
    “errors”: [
    {
    “message”: “Sorry, that page does not exist”,
    “code”: 34
    }
    ]
    }
    Is this endpoint only supposed to be for chunked uploads? Or is this an error on your side?

After this, I executed the following:

~ ❯❯❯ twurl -X POST -H upload.twitter.com "/1.1/media/upload.json" -f ~/Downloads/f4-good-dimensions-800x320.PNG -F media | jq
{
  "media_id": 800916839568121900,
  "media_id_string": "800916839568121857",
  "size": 107022,
  "expires_after_secs": 86400,
  "image": {
    "image_type": "image/png",
    "w": 800,
    "h": 320
  }
}

~ ❯❯❯ twurl -X POST -H ads-api-sandbox.twitter.com "/1/accounts/gq0zn9/cards/website?name=test-website-card&website_title=test-website-title&website_url=https://twitter.com/&image_media_id=800916839568121900" | jq
{
  "errors": [
    {
      "code": "NOT_FOUND",
      "message": "800916839568121900 was not found",
      "parameter": "image_media_id"
    }
  ],
  "request": {
    "params": {}
  }
}
  • Are images uploaded through upload.twitter.com not available in the sandbox? Or what is the explanation here?

  • If I’m inferring correctly from here — there is no need from step 2 in my original question? Meaning the steps to create a website card with an image is just 1 and 2?


#4

@CMP: Thanks for the follow up.

Do you not need to use the POST accounts/:account_id/account_media endpoint in this process—point 2, above.

Instead, simply use the media_id_string in the response after making a request to the POST media/upload endpoint. (Note that this is not an Ads API endpoint and, thus, there is no sandbox equivalent.) Then, use this ID to make a request to the POST accounts/:account_id/cards/website endpoint.


Thanks for providing the example requests—that’s really helpful!

You’re making a successful request to the POST media/upload endpoint.

The second request—the one to the POST accounts/:account_id/cards/website endpoint—is failing because you’re using 800916839568121900 instead of 800916839568121857. This is a peculiarity of twurl.

Please try using 800916839568121857 and let us know if it works.


#5

The second request—the one to the POST accounts/:account_id/cards/website endpoint—is failing because you’re using 800916839568121900 instead of 800916839568121857. This is a peculiarity of twurl.

Please try using 800916839568121857 and let us know if it works.

This worked and it resolved my problem, thanks!

It kinda sucks that twurl, being the ubiquitous debugging tool here, returns a bogus media_id. It would be really helpful to point out that, as with JS, twurl itself cannot represent IDs correctly (it would’ve saved me a few hours of pointless debugging on my end)—or maybe I missed it?

A final follow-up question: What is the point of the POST account_media, POST creative_media, etc. endpoints?