djangofacebook-sharerfacebook-ui

Facebook Share Button from Django App


My Facebook share button is not picking up the meta tags on my Django app. I'm now trying a more custom function but get an error "could not resolve object at URL http://localhost:8000/."

I've tried many different approaches and I can't get the meta tags to work or else I get this 'resolve object' error. I have 'http://localhost:8000/' specified as my Site URL in the Facebook App settings. I want users to be able to share to facebook the {{ poll.question }} content from my html page...where am I going wrong?

<meta property="og:url"                content="http://localhost:8000/" />
<meta property="og:type"               content="article" />
<meta property="og:title"              content="Check out this forecast on CASSIE: {{ poll.question }}"/>
<meta property="og:description"        content="Join Cassie to forecast this and more! See how accurate you are at \
                                                predicting the future!" />
<meta property="og:image"              content="{{MEDIA_URL }}/social/logo_words.png" />


<div class="text-center" id="fb-root">
  <div class="btn btn-primary" onclick="fbshare()"></div>
</div>

{% block js %}
<script>
    function fbshare(){
        FB.ui({
          method: 'share',
          href: 'http://localhost:8000/',
          picture: '{{MEDIA_URL }}/social/logo_words.png',
          caption: 'Forecast the Future with CASSIE',
          description: 'Forecast future events- earn points for correct predictions!'
        }, function(response){});
    }
</script>
{% endblock js %}

Solution

  • Possible reason is your are trying to serve it from localhost. Facebook needs to reach your server/site to pick up information.

    You should test it by deploying somewhere like Heroku or use any tools like https://ngrok.com/ http://localtunnel.me/ etc to expose localhost to outside world.