简体   繁体   中英

Display facebook photos on a website to users who aren't logged in

I have a photo album I want to display on a website to anybody who visits. At the moment I'm using FQL to show the album but it only shows to me when I'm logged in to my account. Is there a way anybody knows of to authenticate a public user or even somebody without a facebook account to view the album?

Current code:

var fbAppId = 'xxxxxxxxx';

window.fbAsyncInit = function() {
    FB.init({
      appId      : fbAppId, // App ID
      status     : true,    // check login status
      cookie     : true,    // enable cookies to allow the server to access the session
      xfbml      : true     // parse page for xfbml or html5 social plugins like login button below
    });
};

(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.net/en_US/all.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));

function getPhoto() {
    FB.api(
        {
          method: 'fql.query',
          query: 'SELECT src_big, src FROM photo WHERE album_object_id = "[my album id]"'
        },
        function(response) {
          if (!response || response.error) {
            console.log(response.error);
          } else {
            console.log(response);
            for (var i = 0; i < response.length; i++) {
              $('#result').append('<img src=' + response[i].src + ' alt="" /> ');
            } 
          }
        }
    );
};

If you are okay using a third party facebook widget , a simple solution without any programming knowledge to displaying facebook photos on a website to users who aren't logged in by using

<iframe  src="http://facebookgalleria.com/gallery.php?id=nike&rows=4&margin=10&cols=3&width=170&font_size=11&title_color=000&hide_next_back=0&share_buttons=1&shape=rectangle&frame=1" scrolling="no" marginheight="0" frameborder="0" width="551" style="height: 769px;"></iframe>

Change 'nike' in the url to your facebook page username, copy the code and paste it on your html website editor and it'll display neatly. Or customize your gallery at http://facebookgalleria.com . However, if you display photos from your personal facebook account, you need to go to the website and connect with facebook first. Then you generate your code that will work on your website without your customers having to log in to see them.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM