Google+共享网址:它使用什么参数? [英] Google+ share url: what parameters does it use?

查看:55
本文介绍了Google+共享网址:它使用什么参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想像在Stackoverflow上一样.我不希望使用+1按钮(加载需要花费一些时间,所有页面的加载速度都稍慢一些). 我查看了源页面,但没有找到任何信息...他们如何做到的??

I want to make like on Stackoverflow. I do not whant +1 button (it takes some time for loading and all page loading are little slower). I've looked on source page and didn't found any info of it... How do they do it???

在Facebook上,这是:

On facebook this is:

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

Something like this must be for google+ share to, but i didn't found any helpful information during my search.

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

I know I can use such url: https://plus.google.com/share?url=my_url, but it's not enough - I also need share title, text and image, but what url GET parameters to use for this purpose?

提前谢谢!

推荐答案

共享链接支持两个URL参数:url(用于目标URL)和hl(用于语言代码).

The share link supports two url paramaters: url, for the target url, and hl, for a language code.

目标网址上的结构化标记确定了在Google+上共享的标题,描述和图像.例如,如果您在要共享的页面上添加schema.org标记或OpenGraph标记,则该页面似乎会像对其+1按钮一样进行拾取.

The structured markup on the target url determines the title, description and image shared on Google+. For example, if you add schema.org markup or OpenGraph tags to the page that you're sharing it appears to pick it up just like it does for the +1 button.

官方文档中,该+ Snippet表示

In the official docs for the +Snippet it indicates that schema.org markup is preferred. So if you add markup to your page that looks something like this:

<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字段中读取的图像.

you will see your title read from the name field and image from the aptly named image field.

或者,您可以在页面顶部添加OpenGraph标记,以指定相同的字段,如下所示:

Alternatively, you can add OpenGraph tags to the head of your page to specify the same fields like this:

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

这篇关于Google+共享网址:它使用什么参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆