【发布时间】:2015-09-18 11:07:35
【问题描述】:
我正在尝试在我的网站上运行 Skype SDK,这将允许我最初登录 Skype。我正在使用的代码来自https://msdn.microsoft.com/EN-US/library/dn962162(v=office.16).aspx,但是当通过它运行 javascript 时会抱怨一个未定义的对象。这是javascript代码(忽略$j,这是我们运行jQuery所需要的),
/**
* This script demonstrates how to sign the user in and how to sign it out.
*/
$j(function () {
'use strict'; // create an instance of the Application object;
// note, that different instances of Application may
// represent different users
var Application
var client;
Skype.initialize({
apiKey: 'SWX-BUILD-SDK',
}, function (api) {
Application = api.application;
client = new Application();
}, function (err) {
alert('some error occurred: ' + err);
});
// whenever state changes, display its value
client.signInManager.state.changed(function (state) {
$j('#application_state').text(state);
});
// when the user clicks on the "Sign In" button
$j('#signin').click(function () {
// start signing in
client.signInManager.signIn({
username: $j('#username').text(),
password: $j('#password').text()
}).then(
//onSuccess callback
function () {
// when the sign in operation succeeds display the user name
alert('Signed in as ' + client.personsAndGroupsManager.mePerson.displayName());
},
//onFailure callback
function (error) {
// if something goes wrong in either of the steps above,
// display the error message
alert(error || 'Cannot sign in');
});
});
// when the user clicks on the "Sign Out" button
$j('#signout').click(function () {
// start signing out
client.signInManager.signOut()
.then(
//onSuccess callback
function () {
// and report the success
alert('Signed out');
},
//onFailure callback
function (error) {
// or a failure
alert(error || 'Cannot sign in');
});
});
});
当我运行它时,它不会进入“Skype.initialize({”代码而是跳转到“client.signInManager.state.changed(function (state){”,这是它抛出这个错误的时候“未捕获的TypeError:无法读取未定义的属性'signInManager'”。当通过chrome中的源调试器运行它时,它显示“应用程序”未定义,“客户端”也未定义。所以我的问题是为什么不是这2个在 Skype.initialize 代码中初始化对象?
【问题讨论】:
标签: javascript jquery skype skype4com