我想将 Twitter 时间线嵌入到 Angular 6 应用程序中,但找不到好的解决方案。这是我尝试过的:
ngx-twitter-timeline包。我收到这个警告是因为我使用的是 Angular 6 和 RxJS 6,所以我卸载了它:ng4-twitter-timeline包。它似乎有严重的漏洞:我怎么能得到它?提前致谢,
您不需要安装任何软件包:
索引.html:
<head>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</head>
Run Code Online (Sandbox Code Playgroud)
app.component.html :
<a class="twitter-timeline" href="https://twitter.com/TwitterDev?ref_src=twsrc%5Etfw">
Tweets by TwitterDev
</a>
Run Code Online (Sandbox Code Playgroud)
app.component.ts :
ngAfterViewInit(): void {
(<any>window).twttr.widgets.load();
}
Run Code Online (Sandbox Code Playgroud)
来源:https : //developer.twitter.com/en/docs/twitter-for-websites/timelines/overview.html
正如我所读到的,由于 CORS 安全机制,没有仅使用 Angular 的方式来获取 Twitter 时间线。不过,我发现了一些使用 NodeJS 完成此操作的好教程,例如:
http://thelillysblog.com/2017/02/26/getting-twitter-feed-angular-nodejs/
| 归档时间: |
|
| 查看次数: |
3281 次 |
| 最近记录: |