dsdtumf776629385 2012-12-05 17:35
浏览 147
已采纳

Facebook喜欢按钮没有链接到正确的URL

I have a webpage with the following opengraph metatags:

<meta property="fb:admins" content="myid" />
<meta property="og:title" content="myurl.com" />
<meta property="og:url" content="http://www.myurl.com/" />
<meta property="og:description" content="My description" />
<meta property="og:type" content="website" />
<meta property="og:image" content="http://www.myurl.com/images/image.jpg"/>

Im trying to get a Facebook Like button for every post using this code:

echo '<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.myurl.com%2Fnews.php%3Fid%3D'.$postid.'&amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=trebuchet+ms&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>';

Obviously every like button use a different $postid value, but when i go to my webpage and like the post number 1, i reload the page and the post 3 and 4 have a new like too. I unlike, and it's the same. Really weird and annoying. It's like the posts where connected without having the same URL. Do you know how can i fix this?

  • 写回答

2条回答 默认 最新

  • douzhanlie9209 2012-12-07 20:25
    关注

    I worked around this issue and instead put a Like button inside the details of each post, and that would solve the problem of having lots of Like buttons in the same page linking each other.

    In the details page (i use just one news.php), every time the URL is changed (has different id), the og:url argument is changed the same way.

    news.php?id=1 has an og:url content="http://www.mysite.com/news.php?id=1"
    news.php?id=2 has an og:url content="http://www.mysite.com/news.php?id=2"
    and so on...
    

    Also i change the title and description accordingly to each post so when people share it on Facebook, it will have the correct data and not something generic.

    If you want several Like buttons on the same page, i wouldn't know how...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 速帮,学校需要在外上班没空
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义