Google+分享网址:它使用的参数是什么?

时间:2012-02-26 19:53:49

标签: google-plus share

我想在Stackoverflow上做出类似的东西。我不打算+1按钮(加载需要一些时间,所有页面加载都慢一点)。 我查看了源页面,但没有找到任何信息......他们是怎么做到的?

在Facebook上,这是:

url  = 'http://www.facebook.com/sharer.php?s=100';
url += '&p[title]='     + encodeURIComponent(title);
url += '&p[summary]='   + encodeURIComponent(text);
url += '&p[url]='       + encodeURIComponent(my_url);
url += '&p[images][0]=' + encodeURIComponent(pic);

像这样的东西必须是google + share to,但我在搜索过程中没有找到任何有用的信息。

我知道我可以使用这样的网址:https://plus.google.com/share?url=my_url,但这还不够 - 我还需要共享标题,文字和图片,但是用于此目的的网址是什么?

提前致谢!

4 个答案:

答案 0 :(得分:32)

share link支持两个网址参数:url,用于目标网址,hl用于语言代码。

目标网址上的结构化标记决定了Google+上分享的标题,说明和图片。例如,如果您将schema.org标记或OpenGraph标记添加到您正在共享的页面,它就会像+1按钮一样进行拾取。

在+ {Snippet的official docs中,它表示首选schema.org markup。因此,如果您向页面添加标记,如下所示:

<body itemscope itemtype="http://schema.org/Product">
  <h1 itemprop="name">Shiny Trinket</h1>
  <img itemprop="image" src="image-url"></img>
  <p itemprop="description">Shiny trinkets are shiny.</p>
</body>

您将看到name字段中的标题和来自恰当名称image字段的图片。

或者,您可以将OpenGraph标记添加到页面的开头,以指定相同的字段:

<meta property="og:title" content="..."/>
<meta property="og:image" content="..."/>
<meta property="og:description" content="..."/>

答案 1 :(得分:3)

关于分享互动帖子的以下页面可能会有所帮助: https://developers.google.com/+/web/share/interactive

我已经使用参数“prefilled”进行了测试。此参数允许您通过get参数:

为Google +共享定义预填充文本

https://plus.google.com/share?url=my_url&prefilltext=my_prefilled_text

因此,请深入了解交互式帖子页面,以便找到其他可能的获取参数。

答案 2 :(得分:0)

您可以使用&#34; url&#34;和&#34; prefilltext&#34;。

答案 3 :(得分:0)

您可以使用三个参数,例如:

https://plus.google.com/share?url={url}&text={desc}&hl={language_code}

来源:https://github.com/bradvin/social-share-urls/blob/master/README.md#google