how to get a hangout url from the hangout button

2019-05-28 11:23发布

I want to store the hangout url in a variable after the hangout is initiated on my website. I am using this:

<head>
  <script src="https://apis.google.com/js/platform.js" async defer></script>
</head>

<body>
  <g:hangout render="createhangout" 
   initial_apps="[{ app_id : '184219133185', start_data : 'dQw4w9WgXcQ' }]"             widget_size="175">
  </g:hangout>
</body>

I know I have to use gethangoutUrl() I just don't know the syntax to use it in. Or where to use it.

1条回答
再贱就再见
2楼-- · 2019-05-28 11:37

The answer is: In the gadget or xml file.

Nothing gets returned to your website that you render the button, it is all in the hangout itself. Pass a token in the start_data variable and then in the xml that launches the hangout, you will want to use that as the key in an ajax call back to your app along with any other gapi.hangout data you want associated with that initiated hangout.

var registerHangout = function() {
  var hangoutUrl = gapi.hangout.getHangoutUrl();
  var callbackUrl = 'http://yourwebsite.com/hangout_registration';
  var startData = gapi.hangout.getStartData();

  $.ajax({
    type: "POST",
    url: callbackUrl,
    success: successFunc,
    dataType: 'json',
    data: JSON.stringify({
            "hangoutUrl": hangoutUrl,
            "startData": startData
           })
  });
}
查看更多
登录 后发表回答