Reputation: 146
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?
Upvotes: 11
Views: 39836
Reputation: 3348
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>
Upvotes: 1
Reputation: 7
The answer is very poor. You should use api for login then share content.
require_once 'google-api-php-client-master/src/Google/Client.php';
$client = new Google_Client();
$client->setClientId('YOUR_CLIENT_ID');
$client->setClientSecret('YOUR_CLIENT_SECRET');
$client->setRedirectUri('YOUR_REDIRECT_URI');
$plus = new Google_PlusService($client);
$authUrl = $client->createAuthUrl();
$visibleActions = array(
'http://schema.org/AddAction',
'http://schema.org/ReviewAction');
$authUrl .= '&request_visible_actions=' .
urlencode(implode(' ', $visibleActions));
print '<a href="' . $authUrl . '">Sign in with Google</a>';
Upvotes: -1
Reputation: 145
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);
Upvotes: 1
Reputation: 1253
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="..."/>
Upvotes: 41
Reputation: 3674
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
Upvotes: 11