Creating a website card with an image link


#1

According to https://dev.twitter.com/ads/reference/post/accounts/account_id/cards/website there is an “image_media_id” required field, but in the example, you see the response returns:

“image”: “https://pbs.twimg.com/peacock/398520248267071488/image.jpg”,

I’m guessing the two fields got out of sync and “image_media_id” is the more up-to-date field. My question is: is there a way to provide a pre-existing image URL to the POST cards/website endpoint instead of having to
re-upload an image (https://dev.twitter.com/rest/reference/post/media/upload is the endpoint I think I should be using for this) to satisfy the “image_media_id” requirement?

If my approach is completely wrong, please let me know what the preferred workflow is to create a Website Card. Thanks.


#2

Anyone have any ideas? I’m still suck with this. I’m doing this to create a Website Card within the sandbox, if that helps.


#3

@CMP: Thanks for the questions. From the params table:

A media_id of an image which will be used in this card. This is a write-only field. In response, the API will provide a Twitter URL for this image, that can be reused.

In other words, you must pass in a valid media_id for the image_media_id param, but you’ll see a Twitter URL, like the one you listed above.


#4

@juanshishido Thank you for the response.

@CMP: Thanks for the questions. From the params table:

A media_id of an image which will be used in this card. This is a write-only field. In response, the API will provide a Twitter URL for this image, that can be reused.

In other words, you must pass in a valid media_id for the image_media_id param, but you’ll see a Twitter URL, like the one you listed above.

It’s not obvious that the “media_id” clients provide will be expanded and returned in the “request.params.image” field of the response. It actually looks pretty unintuitive. Maybe specifying in the documentation the name of the field where the expanded url will be returned can make things clearer. A more predictable place to put it in would be within the “data” object in the response.

I don’t think you answered the question I asked, though:

My question is: is there a way to provide a pre-existing image URL to the POST cards/website endpoint instead of having to
re-upload an image (https://dev.twitter.com/rest/reference/post/media/upload is the endpoint I think I should be using for this) to satisfy the “image_media_id” requirement?
If my approach is completely wrong, please let me know what the preferred workflow is to create a Website Card.


#5

That’s a good suggestion about the making a note in the documentation, @CMP.

In terms of the URL found in data.image, it’s not possible to use it to create a website card. If you tried to pass in that value for the image_media_id param, you’d see an error like the following:

{
  "errors": [
    {
      "code": "INVALID_PARAMETER",
      "message": "Expected Long, got \"https://pbs.twimg.com/ad_img/8001234567898765432/24g7Al_e?format=jpg\" for image_media_id",
      "parameter": "image_media_id"
    }
  ],
  ...
}