`I have fetched all the pages of users using manage_page permission, using this code :
<fb:login-button perms="manage_pages" onlogin="getPages()"> list of pages</fb:login-button> <ul id="pages"></ul> <script> window.getPages = function() { FB.api('/me/accounts', function(resp) { var ul = document.getElementById('pages'); for (var i=0, l=resp.data.length; i<l; i++) { var page= resp.data[i]; li = document.createElement('li'); li.innerHTML = "Name: " + page.name ; ul.appendChild(li); } }); }; </script> <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({ appId:'XXXXXXXXXXXXX', cookie:true, status:true, xfbml:true }); </script>
Output for the above code :
- -> -page1
- > -page2
- > -page3
- > -page4
//here it is displaying only the list of pages but i want when the user clicks on
page1 it should redirect them to their facebook page directly.
How can i include/add this code into the above codings and use it ?
https://graph.facebook.com/PAGE_ID/tabs?app_id=APP_ID&method=POST
&access_token=PAGE_ACCESS_TOKEN
Change this line:
li.innerHTML = "Name: " + page.name ;to
li.innerHTML = "Name: <a href='http://facebook.com/"+page.id+"'>"+page.name+"</a>";