【问题标题】:Google+ share url: what parameters does it use?Google+ 分享网址:它使用什么参数?
【发布时间】:2012-03-16 10:17:07
【问题描述】:

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

在脸书上这是:

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+ 分享,但我在搜索过程中没有找到任何有用的信息。

我知道我可以使用这样的 url:https://plus.google.com/share?url=my_url,但这还不够 - 我还需要共享标题、文本和图像,但是为此目的使用什么 url GET 参数?

提前致谢!

【问题讨论】:

标签: google-plus share


【解决方案1】:

您可以使用三个参数,如下所示:

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

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

【讨论】:

    【解决方案2】:

    您可以使用“url”和“prefilltext”。

    【讨论】:

      【解决方案3】:

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

      我已经用“预填充”参数对其进行了测试。此参数允许您通过 get 参数为 google+ 共享定义预填充文本:

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

      因此,请更深入地查看交互式帖子页面,以找到其他可能的获取参数。

      【讨论】:

        【解决方案4】:

        share link 支持两个 url 参数:url,用于目标 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="..."/>
        

        【讨论】:

        • 分享图片怎么样?
        • 你说“目标 url 上的结构化标记决定了标题、描述...:”如果我们想对标题和描述进行编码,我们如何构造 url?
        • 我在浪费时间做这件事..请帮忙
        • @ZeKoU 你不能用 URL 参数指定它们。您必须在目标页面中使用结构化标记。
        猜你喜欢
        • 2015-05-15
        • 1970-01-01
        • 2011-10-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-08
        • 1970-01-01
        • 2012-11-16
        相关资源
        最近更新 更多