-2
        function Pages()
        {
            FB.api(
'/me/accounts',
'GET',
{ fields: 'name,about' },
function(response) {        
    document.getElementById('showPages').innerHTML = response.name + ' ' + response.about ; 
},{ scope: 'manage_pages' }
);
     }

I'm using this function to get the name and about the pages administered by the user who has logged-in into my application.

I'm getting the output as "undefined".

Sarvagya
  • 1
  • 4
  • 1
    FB.api does not ask for permissions, trying to pass a `scope` to it is nonsense. Asking for permissions is what FB.login does. And the response object for this API call (when successful) is not structured like you think it is - so log it to console to inspect and understand it. – CBroe Oct 20 '16 at 10:51
  • in console i m getting response=Object {data: Array[0]} and i have done removing the scope also .. even then i was getting the same output. – Sarvagya Oct 20 '16 at 10:54
  • read this: http://www.devils-heaven.com/facebook-javascript-sdk-login/ – andyrandy Oct 20 '16 at 11:19
  • You still need to ask the user for the permission. – CBroe Oct 20 '16 at 11:26
  • @CBroe Can u plz tell me how to ask ... i am new to development and i m finding the graph api documentation very confusing.. Thanks in Advance ! – Sarvagya Oct 20 '16 at 11:34

2 Answers2

0

It worked .. GET had to be removed..

Sarvagya
  • 1
  • 4
-1

Try FB.api('/me/applications/developer', instead of FB.api('/me/accounts')

May be that works.

Ahmad
  • 5,551
  • 8
  • 41
  • 57