【问题标题】:Like button doesn't give the "like" to the right url喜欢按钮不会给正确的网址“喜欢”
【发布时间】:2014-07-24 10:24:17
【问题描述】:

我在 stackoverflow 上发布了一个问题,但尚未收到任何答案。也许你可以帮助我...... 这就是问题所在:

我页面上的“赞”按钮假设通过给定的不同“href”给不同的 cmets “赞”,将赞数提高到所有赞按钮。

链接到我的网站页面: http://petbuy.co.il/ProductCard.aspx?product_id=7873&friend_Id=1000

  • 查看页面底部并尝试“喜欢”其中一个 cmets,然后刷新页面。如果您使用开发人员工具,您可以看到每个按钮 iframe 获得不同的 href...“每个按钮href中的friend_id”参数更改.. 但 ! 如果您查看控制台日志,您会看到单击“赞”按钮的请求的响应仅使用 url 的第一个参数: 的href是: http://petbuy.co.il/ProductCard.aspx?product_id=7873&friend_Id=1000 它只使用 product_id=7873 而没有friend_Id=1000。

我试图切换参数,这次只需要friend_Id = 1000“..我需要它们:(( 谢谢!!

【问题讨论】:

    标签: asp.net facebook facebook-likebox


    【解决方案1】:

    确保添加以下 Open Graph 元标记:

    <meta property="og:url" content="http://petbuy.co.il/ProductCard.aspx?product_id=7873&friend_Id=1000" />
    

    我在代码中根本没有找到那个标签,它应该在每个页面上,它需要与 URL 匹配。

    还要确保 URL 编码正确,请参见此处:Encode URL in JavaScript?

    ...我在 ASP 中假设 Server.URLEncode。

    始终使用生成器:https://developers.facebook.com/docs/plugins/like-button

    它将准确地向您展示 URL 需要如何显示在代码中。

    【讨论】:

    • 它就在那里,我试图在我多次尝试解决问题时将其删除。我现在退回了它,仍然是同样的问题..:(
    • 似乎在调试器中工作正常,所以我认为这是一个类似按钮的编码问题:developers.facebook.com/tools/debug/og/…
    【解决方案2】:

    like 按钮需要两个不同的 url

    <div class="fb-like" data-href="http://petbuy.co.il/ProductCard.aspx?product_id=7873&amp;friend_Id=2000" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>
    

    和

    <div class="fb-like" data-href="http://petbuy.co.il/ProductCard.aspx?product_id=7873&amp;friend_Id=1000" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>
    

    Meta og:url 是正确的并且描述了页面的 url..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 2014-09-21
      • 2016-04-04
      • 2019-07-03
      • 1970-01-01
      • 1970-01-01
      • 2017-09-06
      相关资源
      最近更新 更多