谷歌加分享和网址中的参数

use*_*291 10 html url share google-plus

我使用Google+在我的网页上分享一些链接,当我尝试共享包含参数的网址时出现问题.例:

http://google.com?n=somethink&link=p/1393007&i=images/icons/gplus-16.png
Run Code Online (Sandbox Code Playgroud)

当您将此URL放入此页面的字段时:

https://developers.google.com/+/plugins/share/
Run Code Online (Sandbox Code Playgroud)

...并单击share按钮,您无法看到有关页面的信息,如姓名,图片和说明.但是当您在"png"之前删除点时,Google会显示有关该页面的数据.

当您'在URL中的任何位置编写符号时,会发生同样的情况.我在Google帮助页面中找不到有关此错误的任何信息.当我使用这样的URL时它可以工作:

http://google.com?n='&link=p/1393007&i=images/icons/gplus-16.png 
Run Code Online (Sandbox Code Playgroud)

...但它不是很优雅的解决方案.

如何编写干净的URL?

Sid*_*Sid 41

目前G + share仅支持两个参数:url,用于目标url,hl,用于语言代码.

https://plus.google.com/share?url=http://www.stackoverflow.com

或者,您可以将OpenGraph标记添加到页面的头部以指定相同的字段,如下所示:(尚未测试)

<meta property="og:title" content="..."/>
<meta property="og:image" content="..."/>
<meta property="og:description" content="..."/>
Run Code Online (Sandbox Code Playgroud)

  • 有趣的是你没有回答他们的问题,但是你回答了我的问题! (7认同)

Chi*_*hah 11

请务必通过Google+分享链接对您要在Google+上分享的链接进行网址编码.

例如:如果要共享链接http://example.com?a=b&c=d,则首先将链接编码为以下链接:

http%3A%2F%2Fexample.com%3Fa%3Db%26c%3Dd
Run Code Online (Sandbox Code Playgroud)

现在,您可以通过分享链接在Google+上分享链接:

https://plus.google.com/share?url=http%3A%2F%2Fexample.com%3Fa%3Db%26c%3Dd
Run Code Online (Sandbox Code Playgroud)