MIME type error when getting tweet json data


#1

Currently getting a JS error when trying to get tweet json data, across 300 sites

Refused to execute script from 'https://cdn.syndication.twimg.com/widgets/timelines/636171672098316288?&lan…es=true&callback=jQuery111104673751692196595_1495193876689&_=1495193876690' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

Has anything related to the MIME type changed in the last 24 hours?


#2

Which API endpoint are you calling? That does not look like an API error.


#3

Hi Andy,

We’re using the old embed widget code still from a couple years ago (i tagged this as REST API as it was the closest bucket on the forum)

Basically, it appears the MIME type has changed on the above url, so JSONP requests are no longer working.

Was this a planned change? Is there anything to be done to revert it?

Thanks


#4

(moving to the Twitter for websites category)

I’m not aware of a change, though that’s not to say it has not happened. I’d recommend grabbing updated embed code from publish.twitter.com.


#5

Hi Andy,

Thanks for updating the category :slight_smile:

We’re actually just using the JSON data directly that’s used for these embed widgets, like lots of other people online.

This approach has worked fine for the last few years - however, today it appears the MIME type on https://cdn.syndication.twimg.com/widgets/timelines has been changed from JSONP to plain JSON - meaning we can no longer access the data because of cross-origin domain rules.

Are you able to look into this further for us?

Thanks


#6

I see - that’s not a documented or supported way to access the data, unfortunately - you should use the proper API endpoints for timelines if you need the JSON formats, rather than trying to access internal endpoints. It’s certainly possible that the MIME type was changed, but our own web widgets do not document those URLs as accessible outside of our own code.


#7

One other thing to mention is that you may be able to use the oEmbed API if you prefer.


#8

Hi,

Is there any update about this??, we are using this approach: http://jasonmayes.com/projects/twitterApi/#sthash.VGX1Fs5=.dpbs

and we recently start having the same issue, do you guys knows any fix for this?.

Regards!

Rigo


#9

As I mentioned above, this was never a supported and documented endpoint so you should not have been depending on it. There are no plans to revert this change. The solution would be to use one of the two methods I listed - the oEmbed API our official widgets.


#10

thanks Andy, it seems to be that this is fixed I just needed to take the endpoint latest code.

Regards!

Rigo


#11

Here is a working version - https://codepen.io/jasonmayes/pen/Ioype.


#12

Given that this is an unsupported endpoint, I’ll point out that the behaviour may change at any time in the future without notice. The supported way to integrate Tweets and timelines into websites is via Twitter for Websites and publish.twitter.com.


#13

Yes, understandable, its not good to depend on it.


#14

If you want a workaround to resolve this problem you can either create your backend endpoint to retrieve the JSON (curl), or you can prepend this to the twitter url:

https://crossorigin.me/

so the result would be

var workaround = protocol + "://crossorigin.me/";
var url = protocol + "://cdn.syndication.twimg.com/widgets/timelines/" + widgetid + "?&lang=" + lang +
                "&suppress_response_codes=true&rnd=" + Math.random();
var ajaxConfig = {
                url: workaround + url,
                method: "GET"
            };
            
            $.ajax(ajaxConfig).done(function (data) {
               ....

#15

Again I need to point out that cdn.syndication.twimg.com is not a supported or documented API endpoint - its availability to be accessed, and this behaviour, may change at any time in the future without notice. You should avoid building any dependency on this URL into your apps and code.


#16