Do Twitter Cards work with POST statuses/update_with_media and POST statuses/update?


#1

I’ve implemented Twitter cards on a page with this structure: https://www.example.com/unique-slug. It is validated and whitelisted. When I manually tweet the URL, the Twitter Card display correctly.

However, manually tweeting the URL isn’t the normal behaviour – tweets containing the URL are posted using the API. I’m using the update_with_media API method to tweet the URL with an image. When tweeting the URL with media, the card doesn’t appear.

Is this intended behaviour or is it a bug? Will switching to the newer POST statuses/update API method solve this?

Thanks
David


#2

If you’re posting media then the image that gets uploaded to pic.twitter.com will be displayed, rather than the card - is that what you’re seeing? update_with_media is deprecated so I’d avoid it, in general, if you can.


#3

I assume even when pic.twitter.com media is uploaded using the newer statuses/update API method (rather than the deprecated method), the card will still not display?


#4

Yes, I believe that is correct, as there is no way to display both kinds of media (image, or card) alongside the Tweet.


#5

I wonder what could be my error… Can you leave me some pointers on where I should change my logic.

When I use ‘https://api.twitter.com/1.1/statuses/update_with_media.json’ - (depricated) to update my status with image, it was successfully posting, however like you pin point, image and cards won’t show at the same time.

So when I use ‘https://api.twitter.com/1.1/statuses/update.json’, I can still post successfully, the card is showing. however the image won’t attach to that tweet (done without card’s url). I use ‘https://upload.twitter.com/1.1/media/upload.json’ to upload the media.

the actual media return was constructed like this:

{
“expires_after_secs” = 86400;
image = {
h = 520;
“image_type” = “image/jpeg”;
w = 329;
};
“media_id” = 725313562713808896;
“media_id_string” = 725313562713808896;
size = 17503;
}

So, I tried this parameters.
let params = [“status”: message, “media_ids”: 725313562713808896 ]

and

let params = [“status”: message, “media_ids”: [725313562713808896] ] // expecting it to be an array of ‘media_ids’

Result: It was successful on both parameters but the image won’t show and just the tweet (card url is working here). I used the same image I used in ‘https://api.twitter.com/1.1/statuses/update_with_media.json

Sequence: I uploaded first the media to ‘https://upload.twitter.com/1.1/media/upload.json’ to get the media_id then proceed to the ‘https://api.twitter.com/1.1/statuses/update.json’ with the above parameters


#6

okay It was resolved. I used ‘media_id_string’ was using ‘media_id’ before. I can see the image now. I will not remove my post so if someone stumbled on this same issue they could make it as a reference.


#7