Hello.js example showing an error

2.3k views Asked by At

I almost copy/pasted this example from the Hello.js website:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="js/vendor/hello/hello.js"></script>
</head>
<body>
<script>
hello.init({ 
    facebook : XXXXXXXXXXX, //Plz note that I replaced a correct ID with the XXXXXXXXXX
},{redirect_uri:'redirect.html'});

hello.on('auth.login', function(auth){

    // call user information, for the given network
    hello( auth.network ).api( '/me' ).then( function(r){
        // Inject it into the container
        var label = document.getElementById( "profile_"+ auth.network );
        if(!label){
            label = document.createElement('div');
            label.id = "profile_"+auth.network;
            document.getElementById('profile').appendChild(label);
        }
        label.innerHTML = '<img src="'+ r.thumbnail +'" /> Hey '+r.name;
    });
});
</script>
<button onclick="hello('facebook').login()">Facebook</button>
</body>
</html>

But when I click the facebook login button the console always shows me this error:

Uncaught TypeError: Cannot read property 'response_type' of undefined

Am I missing something?

Thanks in advance.

2

There are 2 answers

3
Diego López On

You must first register as a Facebook Developer to get an Facebook Developer ID, then you can replace the facebook : XXXXXXXXXXX with your ID. Also you have to specify the return URL. eg.

hello.init({ 
    facebook : 355555184404909, //eg. Facebook ID
},{redirect_uri:'http://yourDomain/return.html'});

you can also register yourself as a developer on these networks Windows Live or Google+

EDIT: Added how to register your domain to a the Facebook Website Platform

You must register your domain on Facebook Developer Settings to allow the library to redirect to your domain Website platform configuration Just enter your domain http://yourDomain on the "Website URL" field.

0
Riten Vagadiya On

You need to create an app as a Facebook Developer (https://developers.facebook.com/apps). You can then retrieve your Facebook App's Client ID.

As shown in hello's official website:

hello.init({ 
    facebook : FACEBOOK_CLIENT_ID,
},{redirect_uri:'redirect.html'});