Problem embedding media images obtained from API call


#1

I was able to connect to twitter api successfully and get a stream of my updates including posted image urls

however when I try to embed the media images on my site they come back blank.

for example this image from a recent post:

it came back from my api call under:
entities/media[ media_url ]

I can see that it’s valid, however when i try to embed it inside an IMG tag it comes back as 0 bytes from the server

my best guess is that the twitter CDN detects and forbids embedding images ?


#2

This is weird, as I’ve just embedded that same image in an IMG tag in a random piece of HTML I knocked together locally, and it shows up fine, e.g.

<html>
<head><title>Testing</title></head>
<body>
<img src="https://pbs.twimg.com/media/B6rnUqOCIAA5bRo.jpg">
</img>
</body>
</html>

Are you able to curl the image from your machine?

Would the Twitter web embeds work for you?

One thing to note is that if you are going to use images from the Twitter servers your site should be complying with the Developer Policy and Display Guidelines for content.


#3

you’re right, it does work from local .html. I am having issues from a local node.js app so I’ll investigate the differences.

when i go to the network and do “copy as curl” it doesn’t generate a url to the source. instead if generates a base64 encoded hash, so that may be a hint


#4

problem solved. it was one of the chrome plugins replacing image tags with base 64 encoded strings.


#5