1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-18 22:15:32 -04:00

new Twitter oEmbed endpoint (shortcode input changes from tweet ID to full URL)

https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-oembed

some hacking is required to continue passing only the tweet ID to <amp-twitter data-tweetid="..."> at the same time. ugh.

https://amp.dev/documentation/components/amp-twitter/#attributes
This commit is contained in:
2020-06-28 11:29:35 -04:00
parent 3bfa8a52cc
commit 99d13da0c7
7 changed files with 15 additions and 14 deletions

View File

@@ -1,8 +1,9 @@
<p class="center">
<amp-twitter
width="375"
height="472"
layout="responsive"
data-tweetid="{{ index .Params 0 }}">
</amp-twitter>
</p>
<amp-twitter
width="375"
height="472"
layout="responsive"
data-tweetid="{{ index (last 1 (split (index .Params 0) "/")) 0 }}"
data-lang="en"
data-align="center"
data-dnt="true">
</amp-twitter>

View File

@@ -1,4 +1,4 @@
{{- $url := printf "https://api.twitter.com/1/statuses/oembed.json?id=%v&dnt=1&omit_script=1&align=center" (index .Params 0) -}}
{{- $url := printf "https://publish.twitter.com/oembed?lang=en&omit_script=true&dnt=true&align=center&url=%s" (index .Params 0 | safeURL) -}}
{{- $json := getJSON $url -}}
<div class="embed tweet">