【发布时间】:2016-11-29 17:25:22
【问题描述】:
我在将 Twitter 时间线与 PhoneGap 3.1.0 应用程序(iOS 版)集成时遇到问题
1) 我生成了一个新的 PhoneGap 3.1.0 应用程序
2) 已添加 iOS 版本
3) 我在 Twitter 中生成了一个时间线小部件
4) 已将 Twitter 小部件中的代码粘贴到页面中:
index.html:
<a class="twitter-timeline" href="https://twitter.com/bill_hallam" data-widget-id="399136844954087424">Tweets by @bill_hallam</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
5) 已将 Twitter 域列入白名单:
config.xml:
<access origin="https://twitter.com" subdomains="true" />
<access origin="http://twitter.com" subdomains="true" />
<access origin="http://platform.twitter.com" />
<access origin="https://platform.twitter.com" />
<access origin="https://cdn.syndication.twimg.com" />
<access origin="http://cdn.syndication.twimg.com" />
6) 从 Xcode 启动 iOS 模拟器
结果:页面是空白的。 Safari 开发控制台显示页面中嵌入了 twitter <iframe> 标签。成功检索所有 js/css 文件。如果他们被列入黑名单,则没有。
有没有人成功地将 Twitter 时间线集成到 PhoneGap 3.1 应用程序中?
【问题讨论】:
-
它在普通浏览器的普通 html 页面中是否有效?如果您只允许白名单中的所有内容以确保您没有丢失域怎么办?
-
@MBillau,正如您建议的那样,我已将 * 添加到空白列表中,但结果是相同的。在常规浏览器中打开 html 页面并显示时间线
-
有什么方法可以在服务器上托管 twitter 时间线页面,然后使用本机移动浏览器 (safari) 打开该页面?这将帮助我们确定问题出在cordova wrapper 还是“更高层”。