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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

<script>
window.fbAsyncInit = function() {
    FB.init({
      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'));
</script>

<div
    class="fb-like"
    data-share="true"
    data-width="450"
    data-show-faces="true">
</div>
<script>
    function checkLoginState() {
        FB.getLoginStatus(function(response) {
            console.log(response.authResponse.accessToken);
            FB.api('/me/accounts', function(response) {
                console.log(JSON.stringify(response));
            });
        });
    }
    FB.login(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') {
            console.log(response.authResponse.accessToken);
        }
    });
</script>
<!--<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();">
</fb:login-button>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Facebook

From novice to tech pro — start learning today.