javascript 将 Google Hangout 嵌入我的网站(从 y 网页功能齐全)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25640441/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:47:27  来源:igfitidea点击:

Embed Google Hangout on my website (fully functional from y webpage)

javascripthangout

提问by Junaid Syed

I have successfully embedded Google Hangouts and the button onto my website. However, none of them is functioning.

我已成功将 Google Hangouts 和按钮嵌入到我的网站中。但是,它们都没有运行。

I can see the Google Hangouts chat page and button on my website but I can't use features like signing in, send meeting invites etc. Everything else works on it except actually logging in. I just want to launch the google hangout from my website so all members can stay on my webpage but still use hangout meeting features.

我可以在我的网站上看到 Google Hangouts 聊天页面和按钮,但我无法使用登录、发送会议邀请等功能。除了实际登录外,其他一切都可以正常工作。我只想从我的网站启动 Google Hangouts所以所有成员都可以留在我的网页上,但仍然可以使用环聊会议功能。

Can anyone advise if Google allows this and whether I am missing some necessary code in order for it to work or it is simply not compatible with other sites?

任何人都可以建议谷歌是否允许这样做,以及我是否缺少一些必要的代码才能使其正常工作,或者它与其他网站不兼容?

回答by RossC

You have a couple of options, but neither will perform in place of a chatroom in the manner I think you want it to.

您有多种选择,但都不会以我认为您希望的方式代替聊天室。

You can embed a Google+ Hangout button as per Google Developers.

您可以根据Google Developers嵌入 Google+ 环聊按钮。

First, make sure that you are specifying a valid app ID, which you can find as described in the Initial app parameters section

Next, you need to make sure that the JavaScript array of apps is valid, and is in fact an array as opposed to just a JavaScript object. In the following example where there is an issue, a JavaScript object is passed instead of an array which will prevent the app from including the Google+ Hangout app.

首先,确保您指定了一个有效的应用程序 ID,您可以按照初始应用程序参数部分中的说明找到该 ID

接下来,您需要确保应用程序的 JavaScript 数组是有效的,并且实际上是一个数组,而不仅仅是一个 JavaScript 对象。在以下存在问题的示例中,传递的是 JavaScript 对象而不是数组,这将阻止应用程序包含 Google+ 环聊应用程序。

Inviting people to the Hangout

邀请他人加入环聊

You can specify a list of people to invite to the Hangout when it starts. The list is only a suggestion to the user that starts the Hangout. Before the Hangout begins, that user will be able to skip the invite or change the list of people.

环聊开始时,您可以指定要邀请其加入的人员列表。该列表只是向发起环聊的用户提供的建议。在环聊开始之前,该用户将能够跳过邀请或更改人员列表。

You can specify an invite (object representing who to invite) via three different identifiers:

您可以通过三个不同的标识符指定邀请(代表邀请对象的对象):

  • Google+ profile ID: This ID is tied to a specific Google+ user. You can obtain this ID in several ways:

  • From the Google+ signin flow. After the user has signed in, you can use the People get API with the special value me to get the authorized user's Google ID.

  • From various other People APIs.

  • From the user's public profile URL. These are usually of the form https://plus.google.com/.

  • From a Hangout app. Several APIs return a Participant object and the person.id field is the Google ID.

  • Google+ circle ID: An identifier of a circle. Note this this is strongly tied to the user that starts the Hangout; only IDs of circles that user owns will work. Obtaining a circle ID is only available via the Circles API for Google Apps.

  • E-mail address: A standard e-mail address.

  • Alternatively, you can invite a phone number to the Hangout. You can invite only a single phone number, and you cannot combine a phone number with inviting other people as documented above

  • Google+ 个人资料 ID:此 ID 与特定的 Google+ 用户相关联。您可以通过多种方式获取此 ID:

  • 来自Google+ 登录流程。用户登录后,您可以使用具有特殊值 me 的 People get API 来获取授权用户的 Google ID。

  • 来自其他各种People API

  • 来自用户的公开个人资料 URL。这些通常采用https://plus.google.com/的形式。

  • 来自环聊应用。几个 API 返回一个 Participant 对象,person.id 字段是 Google ID。

  • Google+ 圈子 ID:圈子的标识符。请注意,这与发起环聊的用户密切相关;只有用户拥有的圈子 ID 才有效。只能通过Circles API for Google Apps获取圈子 ID 。

  • 电子邮件地址:标准电子邮件地址。

  • 或者,您可以邀请电话号码加入环聊。您只能邀请一个电话号码,并且不能将电话号码与上面记录的邀请其他人结合使用

However, if the user is not logged into their Google account, it will redirect to login screen.

但是,如果用户未登录其 Google 帐户,则会重定向到登录屏幕。

The most basicversion of embedding is this:

最基本的嵌入的版本是这样的:

<script src="https://apis.google.com/js/platform.js"></script>
<div id="placeholder-div1"></div>
<script>
  gapi.hangout.render('placeholder-div1', {
    'render': 'createhangout',
    'initial_apps': [{'app_id' : '184219133185', 'start_data' : 'dQw4w9WgXcQ', 'app_type' : 'ROOM_APP' }]
  });
</script>

For better performance an asynchronous load would be better:

为了获得更好的性能,异步加载会更好:

<html>
<head>
    <title>Hangout button demo: Async load</title>
    <link rel="canonical" href="http://www.example.com" />
</head>
<body>
  <div id="placeholder-div"></div>
  <script type="text/javascript">
    window.___gcfg = {
      lang: 'zh-CN'
    };
    (function() {
      var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
      po.src = 'https://apis.google.com/js/platform.js?onload=renderButtons';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();

    function renderButtons(){
      gapi.hangout.render('placeholder-div', {
          'render': 'createhangout',
        });
    }
  </script>
</body>
</html>


Alternatively you could use Hangouts on Airand broadcast from your site, and interactively chat to others. It's quick and easy but isn't a substitute to a 'chat room' type interface as you need to be broadcasting.

或者,您可以使用环聊直播并从您的网站进行广播,并与其他人互动聊天。它既快速又简单,但不能替代“聊天室”类型的界面,因为您需要进行广播。