4 ms·
Print a Twitter feed as a simple HTML blog
needs stunnel, netcat, sed, cat, grep, tr, uniq
thats it
# 1.sh username > 1.json
# 1.sh < 1.json > 1.htm
#!/bin/sh
case $# in :)
;;1)
public_ip=104.244.42.129:443;
public_host="Host: twitter.com";
public_token="Authorization: Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA";
printf "%s\n%s\n%s\n%s\n%s\n" "pid=$HOME/1.pid" "[ $$ ]" "client=yes" "accept=127.0.0.7:80" "connect=$public_ip"|stunnel -fd 0;
x=$(printf "GET / HTTP/1.1\r\n%s\r\nConnection: close\r\n\r\n" "$public_host"|nc -vvn 127.7 80|grep -o "gt=[^;]*"|sed 's/gt=//');
echo gt $x >/dev/stderr;y=$(printf "GET %s HTTP/1.1\r\n%s\r\n%s\r\n%s\r\nConnection: close\r\n\r\n" \
"/i/api/graphql/Vf8si2dfZ1zmah8ePYPjDQ/UserByScreenNameWithoutResults?variables=%7B%22screen_name%22%3A%22$1%22%2C%22withHighlightedLabel%22%3Atrue%7D" \
"$public_host" "$public_token" "X-Guest-Token: $x"|nc -vvn 127.7 80|grep -o "rest_id\":\"[^\"]*"|sed 's/.*\"//');
echo rest_id $y >/dev/stderr;printf "GET %s HTTP/1.1\r\n%s\r\n%s\r\n%s\r\nConnection: close\r\n\r\n" \
"/i/api/graphql/Bn2jPG0Cy8VAOakAoyV_kA/UserTweets?variables=%7B%22userId%22%3A%22$y%22%2C%22count%22%3A500%2C%22withHighlightedLabel%22%3Atrue%2C%22withTweetQuoteCount%22%3Atrue%2C%22includePromotedContent%22%3Afalse%2C%22withTweetResult%22%3Afalse%2C%22withUserResults%22%3Afalse%2C%22withVoice%22%3Afalse%2C%22withNonLegacyCard%22%3Atrue%2C%22withBirdwatchPivots%22%3Afalse%7D" "$public_host" "$public_token" "X-Guest-Token: $x"|nc -vvn 127.7 80
kill -9 $(cat "$HOME"/1.pid)
;;0)
x=$(echo x|exec tr x '\34');
sed -e 's/\\"/\"/g;s/\\n/ /g' -e "s/\"legacy\":/$x/g" \
|exec tr -cd '\34\11\12\40-\176'|exec tr -d '\12'|exec tr '\34' '\12' \
|exec grep -Eo '("created_at":"[^"]*)|("conversation_id_str":"[^"]*)|("url":"[^"]*)|("expanded_url":"[^"]*)|("full_text":"[^"]*)' \
|exec sed '/"created_at":"/s//<br>/; /"conversation_id_str":"/s///;/"url":"/{s///;s/"//g; s/.*/<a href=&>&<\/a>/;};
/"expanded_url":"/{s///;s/.*/<a href=&>&<\/a>/;};/"full_text":"/s///; s| https://[^ ]*| <a href=&>&</a> |g;s/> />/g;
/^RT @/s/$/ (RETWEET)/;s/$/<br>/;s/\\u.\{4\}//g'|uniq
esac
- indigodaddy 5y agoThis is highly rad
- pjc50 5y ago> public_token="Authorization: Whose authorization? Where does this come from?
- teh_klev 5y agoI'm guessing it's the author's application token which is read only. Should probably create your own: https://developer.twitter.com/en/docs/authentication/oauth-2-0/application-only https://developer.twitter.com/en/docs/authentication/oauth-2...
- 1vuio0pswjnm7 5y ago"I'm guessing..." Your guess is incorrect. If you have visited twitter.com, then you, too, have used this token. It's yours as much as it is mine, or anyone else's. It's shared by the public. Any user can see it simply by examining the requests she is sending from her computer when she visits twitter.com. There is nothing "secret" or "personal" about this token: https://stackoverflow.com/questions/61140863/python-downloading-twitter-video-using-python-without-using-twitter-api https://stackoverflow.com/questions/61140863/python-download...
- teh_klev 5y agoOk...fair enough. I did look for a token being sent from my computer whilst not being signed in but obviously missed it.
- 1vuio0pswjnm7 5y agoGood questions. Anyone who visits twitter.com gets this same string of characters ("token"). Open Developer Tools or the equivalent in a popular browser and see for yourself. If you have visited twitter.com recently, then you have received this token. These are the same requests a graphical, Javascript-enabled browser sends, except I prefer not to use a graphical browser nor Javascript. I prefer text-only and using the shell. Easier for me to read.