【问题标题】:Twitter api call no longer working after uploading Flex application上传 Flex 应用程序后 Twitter api 调用不再工作
【发布时间】:2012-08-09 12:22:23
【问题描述】:

我有一个使用 Last.fm 和 Twitter api 的 Flex 应用程序。在我将项目上传到我的网站空间后,Twitter api 调用不再工作,但 Last.fm 仍然工作。我的网址仍然有效:

var getTweetsUrl = "https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=deftonesband&count=3"

这是用于 httpservice 的代码:

    <s:HTTPService id="getTweetsService" url="{getTweetsUrl}" result="displayTweets(event)" fault="twitterFail(event)" resultFormat="e4x" />

每次触发故障事件时,即使 url 是正确的。有人知道这个问题吗?

【问题讨论】:

  • 我认为您需要拥有来自 Twitter 的应用程序密钥,以便您使用他们的服务。当应用程序(在您的情况下为 Flash)在本地运行时,您可能不需要这样做,但任何托管应用程序都需要密钥。

标签: actionscript-3 apache-flex twitter


【解决方案1】:

由于 twitter.com (https://api.twitter.com/crossdomain.xml) 的跨域政策,您无法在未经许可的情况下从其他域调用 twitter api(本地在 flash 播放器中没有跨域检查)

要获得 twitter 用户的许可,您必须使用 oAuth

我认为为 twitter api 实现 oAuth 的最简单方法是使用名为 Tweetr 的 AS3 开源库: http://wiki.swfjunkie.com/tweetr

【讨论】:

  • 这是否也意味着用户必须使用他们的 Twitter 帐户登录?谢谢。
  • 是的,必须使用他们的 Twitter 帐户登录并授予您的应用程序权限
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-13
  • 1970-01-01
  • 2016-01-13
  • 1970-01-01
  • 2021-11-08
  • 1970-01-01
相关资源
最近更新 更多