0

I want to retrieve all page names the user is administering. Ive came across this post which is exactly what I want using graph api and not the FQL. Ive gotten the access token already but I cant debug using the below code. Anybody knows how do I achieve this?

//view all user pages
    private void pageBtn_Click(object sender, EventArgs e)
    {

        FacebookAPI api = new Facebook.FacebookAPI(myToken.Default.token);

        JSONObject pageData = api.Get("/me/account");//pulls all the pages 


        var data = pageData.Dictionary["name"];

        List<JSONObject> pageList = data.Array.ToList<JSONObject>();


        foreach (var page in pageList)
        {
            lbPages.Items.Add(page.Dictionary["name"].String);
        }

    }
Community
  • 1
  • 1
SRA
  • 15
  • 8
  • first things first, have you requested the appropriate permissions (manage_pages) and secondly the connection is "/me/accounts" not "account" so you're missing an s which may be your issue – TommyBs Dec 13 '12 at 09:41
  • hello, thanks for replying. okay ive changed to /me/accounts already and the error message is pointing to this statement "var data = pageData.Dictionary["name"];" something about not present in the dictionary. and yes, Ive requested that permission... – SRA Dec 14 '12 at 01:38

1 Answers1

0

Okaay I think Ive got it. I used the below code to return me all the pages I have. Thanks TommyBs for the first stepping stone!

            FacebookAPI api = new Facebook.FacebookAPI(myToken.Default.token);

            JSONObject pageData = api.Get("/me/accounts");

            var data = pageData.Dictionary["data"];

            List<JSONObject> pageList = data.Array.ToList<JSONObject>();

            foreach (var page in pageList)
            {
                // myFriendsData.Add(friend.Dictionary["id"].String, friend.Dictionary["name"].String);
                listBox1.Items.Add(page.Dictionary["name"].String);
            }
SRA
  • 15
  • 8