10

Google+ を使用してページのリンクを共有していますが、パラメータを含む URL を共有しようとすると問題が発生します。例:

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

この URL をこのページのフィールドに入力すると:

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

...shareボタンをクリックすると、名前、画像、説明などのページに関する情報が表示されません。ただし、「png」の前のドットを削除すると、Google はページに関するデータを表示します。

'URL の任意の場所にシンボルを記述しても、同じことが起こります。Google ヘルプ ページでこのエラーに関する情報を見つけることができません。次のような URL を使用すると機能します。

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

...しかし、それはあまりエレガントなソリューションではありません。

きれいな URL を書くには?

4

5 に答える 5

41

現在、G+ 共有は、ターゲット URL の url と言語コードの hl の 2 つのパラメーターのみをサポートしています。

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="..."/>
于 2012-09-09T13:41:46.527 に答える
11

Google+共有リンクを介してGoogle+で共有するリンクをURLエンコードするようにしてください。

例:リンクを共有する場合http://example.com?a=b&c=d、最初のURLはリンクを次のようにエンコードします。

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

これで、共有リンクを介してGoogle+でリンクを共有できます。

https://plus.google.com/share?url=http%3A%2F%2Fexample.com%3Fa%3Db%26c%3Dd
于 2012-08-09T16:36:21.907 に答える
1
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);

このリンクを参照してください

于 2015-09-28T11:50:59.103 に答える
-1

答えは非常に貧弱です。ログインに api を使用してから、コンテンツを共有する必要があります。

 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>';
于 2016-09-16T10:22:29.890 に答える