Video_content_id in cards API


#1

In some cases I am able to use the video_content_id in a Cards API response (like a website card) and retrieved media details from the media_library GET by media_key. For some card responses the video_content_id returns an error in the media_library endpoint that it is not a valid media key.

From looking at the media ids/keys, it appears the media_key has a 13_ or 3_ prefix to it. The cases where the Card’s video_content_id fails, it does not have the 13_ or 3_ prefix. If I add a 13_ prefix to the video_content_id the media_library API succeeds and returns the correct media.

Is there a reliable rule I can follow to determine if a video_content_id needs to have a prefix appended, and whether I should use 13_ or 3_ or something else?


#2

@joe-vidmob: There’s currently an inconsistency in the type of values we return in the video_content_id response attribute. In some cases, as you’ve mentioned, we return a media key—a value like 13_1004831418474684417—and in others, we return a media ID—a value like 994991768587321344 (does not include the prefix).

For videos, the prefix values will either be 7_ or 13_. Because of the way our video cards have historically worked, it’s guaranteed that the video asset will be in the media library (unless it’s been deleted).

For images, we don’t currently return any reference to the media key (or ID). (Sometimes it’s in the image URL field, but I would not recommend relying on that.)

One question for you. Could you please share a video card response that contains a 3_ prefix? That prefix corresponds to images.

Thanks!


#3

Thank you for your response. The 3_ prefix I was referring to was likely for images.

If I get a media ID instead of a key, would you recommend I add the prefix to retrieve it by the key? Are there rules for when 7_ or 13_ should be used? Or should I try both?

Thank you,

  • Joe

#4

For 7_ vs 13_, it depends on the media category that is specified for the video during the upload. The former corresponds to Tweet video and the latter to Amplify video. In terms of identifying which one it is from the cards response, you could look at the video URL, but there are no guarantees. See the comparison below.

$ twurl -H ads-api.twitter.com "/4/accounts/18ce54d4x5t/cards/video_website?card_ids=67swn,67si4"
{
  "request": {
    "params": {
      "card_type": "video_website",
      "card_ids": [
        "67swn",
        "67si4"
      ],
      "account_id": "18ce54d4x5t"
    }
  },
  "next_cursor": null,
  "data": [
    {
      "video_poster_height": "9",
      "name": "using a Tweet video",
      "website_shortened_url": "https://t.co/zadeUSVD18",
      "video_height": "9",
      "video_url": "https://video.twimg.com/ext_tw_video/vmap/1040675270053646337.vmap",
      "content_duration_seconds": "10",
      "video_owner_id": "756201191646691328",
      "video_content_id": "7_1040675270053646337",
      "preview_url": null,
      "website_display_url": "developer.twitter.com",
      "id": "67swn",
      "account_id": "18ce54d4x5t",
      "video_width": "16",
      "video_hls_url": "https://video.twimg.com/ext_tw_video/1040675270053646337/pu/pl/DsnisDRwLO6kCFjB.m3u8?tag=5",
      "website_dest_url": "https://developer.twitter.com",
      "created_at": "2018-09-14T19:16:04Z",
      "card_uri": "card://1040680600842059776",
      "title": "Twitter Developers",
      "website_url": "https://developer.twitter.com",
      "updated_at": "2018-09-14T19:16:04Z",
      "video_poster_url": "https://pbs.twimg.com/ext_tw_video_thumb/1040675270053646337/pu/img/WAEOAGCH62mJiPxo.jpg",
      "video_poster_width": "16",
      "deleted": false,
      "card_type": "VIDEO_WEBSITE"
    },
    {
      "video_poster_height": "9",
      "name": "looking-at-video_content_id",
      "website_shortened_url": "https://t.co/zadeUSVD18",
      "video_height": "9",
      "video_url": "https://video.twimg.com/amplify_video/vmap/1004831418474684417.vmap",
      "content_duration_seconds": "20",
      "video_owner_id": "756201191646691328",
      "video_content_id": "13_1004831418474684417",
      "preview_url": null,
      "website_display_url": "developer.twitter.com",
      "id": "67si4",
      "account_id": "18ce54d4x5t",
      "video_width": "16",
      "video_hls_url": "https://video.twimg.com/amplify_video/1004831418474684417/pl/fLoSS3RQepB0iCl3.m3u8?tag=2",
      "website_dest_url": "https://developer.twitter.com",
      "created_at": "2018-09-14T17:40:07Z",
      "card_uri": "card://1040656454011707392",
      "title": "Twitter Developers",
      "website_url": "https://developer.twitter.com",
      "updated_at": "2018-09-14T17:40:07Z",
      "video_poster_url": "https://pbs.twimg.com/amplify_video_thumb/1004831418474684417/img/7IgmoQLNtoC06WVT.jpg",
      "video_poster_width": "16",
      "deleted": false,
      "card_type": "VIDEO_WEBSITE"
    }
  ]
}

#5

Thank you @juanshishido, that helps!