Reputation: 4818
I'd like to embed a Twitter timeline into an Angular 6 application, but I couldn't find a good solution. This is what I've tried:
ngx-twitter-timeline
package. I got this warning because I'm using Angular 6 and RxJS 6, so I uninstalled it:ng4-twitter-timeline
package. It seems to have critical vulnerabilities:How could I get it? Thanks in advance,
Upvotes: 5
Views: 5552
Reputation: 1
To embed twitter timeline in Angular there are 2-3 packaged available, I have used this one it works fine, Also is has many other functionalities. https://www.npmjs.com/package/ngx-twitter-widgets
npm i ngx-twitter-widgets
...
imports: [
BrowserModule,
NgxTwitterWidgetsModule
],
...
<ngx-twitter-timeline
[source]="{sourceType: 'profile', screenName: 'StackOverflow'}"
[options]="{height: '400'}" (onLoad)="onLoad($event)">
</ngx-twitter-timeline>
Here is documented properly... https://romikmakavana.github.io/ngx-twitter-widgets
Upvotes: 0
Reputation: 6885
You don't need to install any package:
index.html:
<head>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</head>
app.component.html:
<a class="twitter-timeline" href="https://twitter.com/TwitterDev?ref_src=twsrc%5Etfw">
Tweets by TwitterDev
</a>
app.component.ts:
ngAfterViewInit(): void {
(<any>window).twttr.widgets.load();
}
Source: https://developer.twitter.com/en/docs/twitter-for-websites/timelines/overview.html
Upvotes: 18
Reputation: 4818
As I've read, there's no Angular-only way of getting the Twitter timeline due to CORS security mechanism. However, I found some good tutorials to do it using NodeJS, like this one:
http://thelillysblog.com/2017/02/26/getting-twitter-feed-angular-nodejs/
Upvotes: 0