Heim  >  Artikel  >  php教程  >  网页上facebook分享功能具体实现

网页上facebook分享功能具体实现

PHP中文网
PHP中文网Original
2016-05-25 17:13:22979Durchsuche

本文为大家介绍下网页上facebook分享功能的具体实现,详细代码请看本文

代码如下:

<span style=" font-family: Verdana, Arial, Helvetica, sans-serif; word-wrap: normal; word-break: normal; line-height: 19.5px;"><span style="word-wrap:normal; word-break:normal; line-height:19px"></span></span>


题外话:直接跳到facebook登录页面的分享按钮:

url为: http://www.php.cn

其中的u参数为你要分享的链接。t 参数目前还没弄清楚是干什么的。

facebook分享功能的实现:

分享页面设定

1.一个链接: 参数是要分享的页面的链接

代码如下:

<a style="display:inline-block;width:35px; height:40px; position:relative; top:10px; left:48px; " 
title="Share on Facebook" target="_blank" 
onclick="javascript:window.open(&#39;http://www.facebook.com/sharer.php?u=&#39;+encodeURIComponent(&#39;https://www.baidu.com&#39;)+&#39;&t=&#39;+encodeURIComponent(document.title), &#39;newWindow&#39;, &#39;width=800, height=400&#39;,&#39;center&#39;);void(0);">



2.fb识别的标签:

代码如下:

<title>test</</span>title> 
<meta property="og:image" content="test/test.jpg" /> 
<meta property="og:description" content="test>" /> 
<meta property="og:url" content="https://www.baidu.com" />


注意:

1.title fb可以自动读取要分享页面的title 这个要设置在fb的sharer.php参数里
你也可以自己设置 方式就是

 代码如下:

<meta property="og:title" content="test" />


2.image标签 可以写多个 分享人可以自己选择图片

3.url就是你的要分享的页面
4.description 介绍信息

提示:

图片像素必须是100*100 这样的格式 我用90*90 就是OK的

例如:300*100 150*50在www.facebook.com图片会截取90x90图片显示就不正确了
如果图片小了 更不行了,分享的那个弹出框就不会显示你的图片 这个情况发生在图片小于90x90的情况吧

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:目录复制和删除Nächster Artikel:先识别标签后计算的模板思路