【问题标题】:Firing Dailymotion change events触发 Dailymotion 更改事件
【发布时间】:2014-02-16 13:04:21
【问题描述】:

我有一个非常基本的问题,我有以下代码,我基本上只是想登录dailymotion。

window.dmAsyncInit = function()
{
    DM.init({apiKey: 'MyAppID', status: true, cookie: true});
    console.log('sdk loaded');
};

DM.Event.subscribe('auth.login', function(response)
        {
            // do something with response
    if (response.status == 'connected')
        {
        console.log('connected');
        testAPI();
        }
    else
        {
        DM.login(function(response)
                {
                    if (response.session)
                    {
                        if (response.session.scope)
                        {
                            // user is logged in and granted some permissions.
                            // perms is a comma separated list of granted permissions
                        }
                        else
                        {
                            // user is logged in, but did not grant any permissions
                        }
                    }
                    else
                    {
                        // user is not logged in
                    }
                }, {scope: 'read write'});

        }


        });
(function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol + '//api.dmcdn.net/all.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s);
}());


function testAPI() {
    DM.api('/user/rs', {fields: "screenname"}, function(response)
            {
                alert('Name is ' + response.screename);
            });
}

我已订阅 auth.login,但我不确定如何启动此活动。我想为 dailymotion 创建一个登录按钮并将此事件绑定到该按钮。我怎样才能做到这一点?

【问题讨论】:

    标签: javascript api login event-handling dailymotion-api


    【解决方案1】:

    您必须创建一个按钮,该按钮将在“onclick”事件上触发登录功能。

    http://www.dailymotion.com/doc/api/sdk-javascript.html#sdk-javascript-method-login描述了如何登录

    基本上就是调用 DM.login 函数,它会提示用户登录(会弹出一个窗口让用户登录)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-26
      • 2021-08-24
      • 2021-09-30
      • 2014-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多