Lullabot / amp-library

Convert HTML to AMP HTML and report HTML compliance with the AMP HTML specification
Other
382 stars 182 forks source link

Twitter embed issue #199

Open tapankumar opened 7 years ago

tapankumar commented 7 years ago

I am seeing twitter embed code issue since last few days.

Issue (In console of Chrome/Firefox): Tweet is not getting rendered: Refused to execute script from 'https://cdn.syndication.twimg.com/tweets.json?callback=__twttr.callbacks.cb0&ids=915037232926400512%3Fref_src%3Dtwsrc%255Etfw&lang=en&suppress_response_codes=true&tz=GMT%2B0530' because its MIME type ('') is not executable, and strict MIME type checking is enabled.

Original block quote:

<blockquote class="twitter-tweet" data-lang="en">
<p dir="ltr" lang="en"><a href="https://twitter.com/hashtag/Judwaa2?src=hash&amp;ref_src=twsrc%5Etfw" rel="nofollow">#Judwaa2</a> Fri 16.10 cr, Sat 20.55 cr, Sun 22.60 cr. Total: ₹ 59.25 cr. India biz... Will score BIG numbers again today [holiday]...</p>
&mdash; taran adarsh (@taran_adarsh) <a href="https://twitter.com/taran_adarsh/status/914736553062289408?ref_src=twsrc%5Etfw" rel="nofollow">October 2, 2017</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

Converted AMPCODE with this library.

<amp-twitter data-lang="en" height="694" width="486" layout="responsive" data-tweetid="914736553062289408?ref_src=twsrc%5Etfw"></amp-twitter>

If i changed my block quote to (Removed query string parameter from 914736553062289408):

<blockquote class="twitter-tweet" data-lang="en">
<p dir="ltr" lang="en"><a href="https://twitter.com/hashtag/Judwaa2?src=hash&amp;ref_src=twsrc%5Etfw" rel="nofollow">#Judwaa2</a> Fri 16.10 cr, Sat 20.55 cr, Sun 22.60 cr. Total: ₹ 59.25 cr. India biz... Will score BIG numbers again today [holiday]...</p>
&mdash; taran adarsh (@taran_adarsh) <a href="https://twitter.com/taran_adarsh/status/914736553062289408" rel="nofollow">October 2, 2017</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

Converted AMPCODE with this library.

<amp-twitter data-lang="en" height="694" width="486" layout="responsive" data-tweetid="914736553062289408"></amp-twitter>

Which just works fine. Please help.

tapankumar commented 7 years ago

I have fixed this in below code.

src/Pass/TwitterTransformPass.php

Fixed getTweetId function.

//$tweet_id = $matches[1]; $tweet_id = strtok($matches[1], "?");

Let me know if this is the right way. If yes, let me know if i can send a PR.

BrunoViera commented 7 years ago

Hello all! I have the same issue. Waiting this PR 👍