How to get twitter user image?

I am creating a website where people post their Twitter username. Now I want to download twitterimage with the name that is placed. I have already searched the Internet, but cannot find a good easy way to implement this. Do I need to use some fancy twitter api or something else? Any simple APIs? (is it just for a simple site) or a URL with a name as a variable in it?

+4
source share
2 answers

it works:

<!DOCTYPE html> <html> <head> <script type="text/javascript"> function GetImage(){ var txtBox = document.getElementById("twit"); var imgTwitter = document.getElementById("imgTwitter"); imgTwitter.src = "http://api.twitter.com/1/users/profile_image/" + txtBox.value; } </script> </head> <body> <input name="twit" id="twit" type="text"><a href="#" onclick="javascript:GetImage();">Get Image</a> <img id="imgTwitter" > </body> </html> 
+5
source

From this question: fooobar.com/questions/275915 / ...

 https://twitter.com/[screen_name]/profile_image?size=mini https://twitter.com/[screen_name]/profile_image?size=normal https://twitter.com/[screen_name]/profile_image?size=bigger https://twitter.com/[screen_name]/profile_image?size=original 

 function ClickFunction() { document.getElementById("content").innerHTML = ""; var frag = document.createDocumentFragment(); var uname = document.getElementById("name").value; var SRCmini = "https://twitter.com/" + uname + "/profile_image?size=mini"; var SRCnormal = "https://twitter.com/" + uname + "/profile_image?size=normal"; var SRCbigger = "https://twitter.com/" + uname + "/profile_image?size=bigger"; var SRCoriginal = "https://twitter.com/" + uname + "/profile_image?size=original"; frag.appendChild(document.createTextNode(SRCmini)); frag.appendChild(document.createElement("br")); var IMGmini = frag.appendChild(document.createElement("img")); IMGmini.src = SRCmini; frag.appendChild(document.createElement("br")); frag.appendChild(document.createTextNode(SRCnormal)); frag.appendChild(document.createElement("br")); var IMGnormal = frag.appendChild(document.createElement("img")); IMGnormal.src = SRCnormal; frag.appendChild(document.createElement("br")); frag.appendChild(document.createTextNode(SRCbigger)); frag.appendChild(document.createElement("br")); var IMGbigger = frag.appendChild(document.createElement("img")); IMGbigger.src = SRCbigger; frag.appendChild(document.createElement("br")); frag.appendChild(document.createTextNode(SRCoriginal)); frag.appendChild(document.createElement("br")); var IMGoriginal = frag.appendChild(document.createElement("img")); IMGoriginal.src = SRCoriginal; frag.appendChild(document.createElement("br")); document.getElementById("content").appendChild(frag); } 
 <input id="name" value="wikipedia" /><br /> <button onclick="ClickFunction()">Click here!</button><br /><br /> <div id="content"></div> 
-1
source

Source: https://habr.com/ru/post/1341713/


All Articles