Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google plus share and parameters in url

I use Google+ to share some links on my page and there is a problem when I try to share an URL containing parameters. Example:

http://google.com?n=somethink&link=p/1393007&i=images/icons/gplus-16.png

When you put this URL into the field at this page:

https://developers.google.com/+/plugins/share/

...and click on the share button, you can't see information about page like name, picture and description. But when you delete the dot before "png", then Google shows data about the page.

The same thing happens when you write the ' symbol anywhere in the URL. I can't find any information about this error in Google Help Pages. It works when I use an URL like this:

http://google.com?n='&link=p/1393007&i=images/icons/gplus-16.png 

...but it isn't very elegant solution.

How to write clean URLs?

like image 387
user1502291 Avatar asked Aug 08 '12 15:08

user1502291


People also ask

What is G+ URL?

In your browser, type: plus.google.com and sign up with your Google account.

What does a Google Plus URL look like?

You just need to type in short URLs like “google.com/+techwalls” or “plus.google.com/+tuando” to reach those pages. Google Plus launches vanity URLs for verified accounts.


4 Answers

currently G+ share supports only two parameters: url, for the target url, and hl, for a language code.

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

Alternatively, you can add OpenGraph tags to the head of your page to specify the same fields like this: (haven't tested yet)

<meta property="og:title" content="..."/>
<meta property="og:image" content="..."/>
<meta property="og:description" content="..."/>
like image 83
Sid Avatar answered Nov 08 '22 03:11

Sid


Make sure you URL encode the link you want to share on Google+ via the Google+ share link.

For example: if you want to share the link http://example.com?a=b&c=d, first URL encode the link to look like:

http%3A%2F%2Fexample.com%3Fa%3Db%26c%3Dd

Now you can share the link on Google+ through the share link:

https://plus.google.com/share?url=http%3A%2F%2Fexample.com%3Fa%3Db%26c%3Dd
like image 42
Chirag Shah Avatar answered Nov 08 '22 03:11

Chirag Shah


function googleplusbtn(url) {
      sharelink = "https://plus.google.com/share?url="+url;
      newwindow=window.open(sharelink,'name','height=400,width=600');
      if (window.focus) {newwindow.focus()}                                                                                                                                
      return false;
    }   
   var url="www.google.com";
        googleplusbtn(url);

Refer this link

like image 27
Gunasekar Avatar answered Nov 08 '22 05:11

Gunasekar


The share link is intended for native client applications, Flash applications, highly privacy-sensitive sites, and others who may not be able to use the +1 or share button. Adding the following markup to your site will include a simple icon which will pop open a share dialog for your visitors.

    <a href="https://plus.google.com/share?url=https://stackoverflow.com/questions/11868291/google-plus-share-and-parameters-in-url" onclick="javascript:window.open(this.href,
          '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"><img
          src="https://www.gstatic.com/images/icons/gplus-64.png" alt="Share on Google+"/></a>
like image 20
antelove Avatar answered Nov 08 '22 04:11

antelove