facebook, twitter, linkedin等的分享功能

1. facebook分享

方法一:传入参数,此时标题获取的是页面title标签中的内容

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <a href="https://www.facebook.com/sharer.php?u=https://www.google.com">facebook share</a>
</body>
</html>

 

方法二:使用meta参数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- 开放图谱 以便分享出去的内容更准确 -->
    <meta property="og:url" content="需要分享的网址" />
    <meta property="og:type" content="article" />
    <meta property="og:title" content="标题" />
    <meta property="og:description" content="描述" />
    <meta property="og:image" content="图片地址" />
    <!-- 开放图谱 以便分享出去的内容更准确 -->
    <title>Document</title>
</head>
<body>
    <a href="https://www.facebook.com/sharer.php?u=需要分享的网址">facebook share</a>
</body>
</html>

 

 

2. twitter分享

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <a href="https://twitter.com/share?url=需要分享的网址&text=title">twitter share</a>
</body>
</html>

 

 

3. linkedin 此时标题获取的是页面title标签中的内容

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <a href="https://www.linkedin.com/shareArticle?url=需要分享的网址">linkedin share</a>
</body>
</html>

 

posted @ 2019-05-31 10:40  刘倩文  阅读(1284)  评论(0编辑  收藏  举报