Google+ share url: what parameters does it use?

后端 未结 4 1345
醉酒成梦
醉酒成梦 2020-12-08 10:26

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 p

相关标签:
4条回答
  • 2020-12-08 10:48

    You can use "url" and "prefilltext".

    0 讨论(0)
  • 2020-12-08 10:49

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

    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.

    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>
    

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

    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="..."/>
    
    0 讨论(0)
  • 2020-12-08 10:59

    Maybe the following page about sharing interactive posts will be helpful: https://developers.google.com/+/web/share/interactive

    I tested it already with the parameter "prefilled". This parameter allows you to define a prefilled text for the google+ share via get parameter:

    https://plus.google.com/share?url=my_url&prefilltext=my_prefilled_text

    So have a deeper look at the interactive posts page in order to find other possible get parameters.

    0 讨论(0)
  • 2020-12-08 11:01

    You can use three parameters, like so:

    https://plus.google.com/share?url={url}&text={desc}&hl={language_code}
    

    Source: https://github.com/bradvin/social-share-urls/blob/master/README.md#google

    0 讨论(0)
提交回复
热议问题