【问题标题】:Share link with facebook in flex在 flex 中与 facebook 共享链接
【发布时间】:2013-01-20 09:11:42
【问题描述】:

我使用我的 flex 3 应用程序与 facebook 共享了一个链接。

我的代码是:

<mx:Button id="btnFb" click="fbShare(event)" />

  protected function fbShare(event:MouseEvent):void
  {
     openPage('http://www.facebook.com/sharer/sharer.php?u='+getPublicationUrl(),"_popup");
  }

  private function getPublicationUrl():String
  {
      return "http://domain.com/index.html?userid=3&pubid=10";
  }

现在当我与 facebook 分享这个(上图)链接时,它只会分享“http://domain.com/index.html?userid=3”这个链接。它将跳过 &pubid=10

谢谢,

【问题讨论】:

  • 可能不得不逃跑&
  • 是的,但是我喜欢用 url 传递 &pubid=10 吗?

标签: facebook actionscript-3 apache-flex actionscript flex3


【解决方案1】:

您需要在 getPublicationURL 函数的返回数据上使用 encodeURIComponent 函数:

private function getPublicationUrl():String
{
    return encodeURIComponent("http://domain.com/index.html?userid=3&pubid=10");
}

核心问题是原始 URL 采用 &pubid 参数,因为它没有被编码。更多关于 escape、encodeURI 和 encodeURIComponent 的信息可以在这里找到:

When are you supposed to use escape instead of encodeURI / encodeURIComponent?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-02
    • 2014-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-04
    相关资源
    最近更新 更多