-1

Ich versuche, das für die gemeinsame Nutzung von Post auf der Facebook:FB.UI Dialog erscheint nicht in der django Anwendung

<div id="shareBtn" class="btn btn-success clearfix">Share Dialog</div> 

<p>The Share Dialog enables you to share links to a person's profile without them having to use Facebook Login. <a href="https://developers.facebook.com/docs/sharing/reference/share-dialog">Read our Share Dialog guide</a> to learn more about how it works.</p> 

<script> 
document.getElementById('shareBtn').onclick = function() { 
    FB.ui({ 
    display: 'popup', 
    method: 'share', 
    href: 'https://developers.facebook.com/docs/', 
    }, function(response){}); 
} 
</script> 

Ich möchte wissen, was mit dem fehlt aufgrund meiner Anwendung ist nicht das bekommen Dialog freigeben. Hier

ist die Konsole Fehler, den ich gefunden:

(index):292 Uncaught ReferenceError: FB is not defined 
    at HTMLDivElement.document.getElementById.onclick ((index):292) 

Antwort

0

Sie müssen die JavaScript SDK laden:

window.fbAsyncInit = function() { 
    //SDK loaded, initialize it 
    FB.init({ 
     appId  : 'your-app-id', 
     xfbml  : true, 
     version : 'v2.10' 
    }); 

    //now FB is available 
}; 

//load the JavaScript SDK 
(function(d, s, id){ 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.com/en_US/sdk.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
}(document, 'script', 'facebook-jssdk')); 

Weitere Informationen:

Verwandte Themen