我有下面的hangout按钮js代码,我希望当用户点击hangout按钮时会有回调。它不工作了,有什么问题吗?
gapi.hangout.render('hangout-button', {
'render': 'createhangout',
'topic': 'hangout_test',
'invites': "[{'id': 'xxx@gmail.com', 'invite_type': 'EMAIL'}]",
'initial_apps': [{
'app_id': "google_app_id",
'app_type': 'ROOM_APP',
'start_data': {
"user_id": "user_id",
"user_email": "user_email",
"token": "token",
"callback_url": "abc.com/hooks/hangout",
"host": "abc.com",
"callback_data": "user_data"
}
}],
'hangout_type': "normal",
'widget_size': 130
});
发布于 2016-09-26 19:34:44
您需要侦听来自Hanogut的onApiReady
事件,然后在gapi.hangout
上调用getHangoutUrl
。正如在他们的文档中所解释的:https://developers.google.com/+/hangouts/api/gapi.hangout.html#gapi.hangout.ApiReadyEvent
添加相同的代码如下:
gapi.hangout.onApiReady.add(function(eventObj) {
var hangoutUrl = gapi.hangout.getHangoutUrl();
// After saving the url to a variable, pass it using an Ajax call
$.ajax({
type: "POST",
url: callbackUrl,
success: successFunc,
dataType: 'json',
data: JSON.stringify({
"hangoutUrl": hangoutUrl,
})
});
});
https://stackoverflow.com/questions/39709914
复制