Pull Facebook Pages into a Select Form Element

I'm trying to figure out how by clicking a button on my site I can prompt a user for their permission to view pages they are admins of on Facebook.  With the data returned show a dropdown select box that they then can choose one.

Are there any tutorial or pre-made scripts that do this already?  I know I've seen it on sites before.
LVL 12
Nathan RileyFounderAsked:
Who is Participating?
Nathan RileyFounderAuthor Commented:
I've managed to return the pages into the console with Facebook's documentation.  But not sure how to take it from there and put it into a select of the pageid and page name.

window.fbAsyncInit = function() {
      appId      : '',
      xfbml      : true,
      version    : 'v2.3'

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

    function checkLoginState() {
        FB.getLoginStatus(function(response) {
            FB.api('/me/accounts', function(response) {
        // Handle the response object, like in statusChangeCallback() in our demo
        // code.

    FB.login(function(response) {
        // handle the response
    }, {scope: 'public_profile,manage_pages'});

    FB.login(function(response) {
        if (response.status === 'connected') {
            // Logged into your app and Facebook.
        } else if (response.status === 'not_authorized') {
            // The person is logged into Facebook, but not your app.
        } else {
            // The person is not logged into Facebook, so we're not sure if
            // they are logged into this app or not.

    FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
<!--<div class="fb-login-button" data-max-rows="1" data-size="medium" data-show-faces="false" data-auto-logout-link="false" data-scope="manage_pages"></div>-->
<fb:login-button scope="public_profile,manage_pages" onlogin="checkLoginState();">

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.