I am very new to Twitter Developers and Twitter API. I am currently working on a tight deadline for my academic project so I tried to quickly glance through the documentations but I am overwhelmed.
I am developing a HTML and JavaScript files to display only my Twitter follower count in real time using jQuery. May I know the procedure I need to follow in order to successfully retrieve follower_count value with jQuery or JavaScript? I believe an API key is necessary right?
I found out that by using “cdn.syndication.twimg com/widgets/followbutton/info json” I can get the follower count. However, I have no idea why the follower count is not showing when I used Google Chrome and Microsoft Edge. The only one that has no problem is Internet Explorer 11.
Have you included widgets.js on the page? Twitter Publish
Hi, I discovered the problem I faced is due to being blocked by CORS policy. However, I have yet to fix it. By the way, I didn’t add widgets.js. May I know how do I include it in my page?
oh, i misunderstood what you wanted to show - i don’t think that endpoint is meant to be public. The normal follow button is from publish.twitter.com but if you want follower counts you can use GET users/show | Docs | Twitter Developer Platform to periodically update the count and store it somewhere server side, and show that to people. The twimg thing isn’t meant to be used by other websites, so you’l always get CORS errors.
2 Likes
This is not a public and documented API endpoint - please do not call it directly as it may change or go away in the future without any notice.
The correct way to retrieve follower count is to use the v2 Users API, or the v1.1 Users Show API.
1 Like
Wait, actually - why not just use shields.io ? eg:
https://img.shields.io/twitter/follow/igorbrigadir.svg?style=social
For my account it’s https://img.shields.io/twitter/follow/igorbrigadir.svg?style=social
2 Likes
I like the idea of using shields.io. It seems far simpler to implement. However, I am overwhelmed by the features in shields.io due to my lack of skills and experience.
I just wanted to show my Twitter follower amount in my web page. How do I use shields.io to only get my Twitter follower amount and implement/embed it in my web page so that my web page can display my Twitter follower amount? Is there a way to extract only the follower amount?
I prefer implementing it using jQuery or JavaScript so that I can periodically request for my Twitter follower amount. My script.js file will request for my Twitter follower amount periodically and the amount will be passed to my index.html web page file to be displayed.
This is what I am doing. I want to get my Twitter follower amount periodically with jQuery or JavaScript inside the script.js file. The script.js file will also be able to see changes in the follower amount and will play notification sound when there is a change. Then, with the help of html, the Twitter follower amount will be shown below the Twitter logo, similar to what happened to this YouTube logo in the screenshot below.
well - ok it’s very hacky but https://img.shields.io/twitter/follow/igorbrigadir.svg if you look at the server response for this, this is an SVG, which is XML - so you can extract the follower number text from that. Otherwise it may be possible to render the entire svg on your site.
The proper way to do it would be to have a server side component that calls the twitter api, caches the result, and your frontend javascript will update from your own server - but this might take more work than it’s worth for just displaying a count - still might be worth doing just to learn a bunch of things.
I will appreciate it if you have sample codes for that as I am quite unexperienced in web designing and coding.
I took a look at the link you sent to me but I am still clueless.
I apologize that what I am going to request for might take up a lot of your time, but can you show me a full JavaScript/jQuery code that will extract the Twitter follower number text from https://img.shields.io/twitter/follow/igorbrigadir.svg? Of course I will not expect a quick reply.
I will appreciate it a lot since I really need it for my academic project.
this example is the closest: jquery - Load a svg file(xml) and extract specific information using javascript - Stack Overflow
After that you can see if you can get the right element out of the XML, using CSS selectors - this is something you can ask on stackoverflow too if you get stuck
system
Closed
#15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.