0

How to convert this to work in .NET 3.5? it does not compile for some reason... complains about "myInfo.data" missing Microsoft CSharp reference that is used in .NET 4.0.

var auth = new CanvasAuthorizer { Perms = "user_about_me,friends_about_me" };

if (auth.Authorize())
{
    var fb = new FacebookClient(auth.Session.AccessToken);
    dynamic myInfo = fb.Get("/me/friends");
    foreach (dynamic friend in myInfo.data  )
    {
        Response.Write("Name: " + friend.name + "<br/>Facebook id: " + friend.id + "<br/><br/>");
    }
}
abatishchev
  • 98,240
  • 88
  • 296
  • 433
001
  • 62,807
  • 94
  • 230
  • 350
  • 1
    Perhaps: http://stackoverflow.com/questions/4568452/dynamic-keyword-problem – Tim M. Jan 21 '13 at 03:05
  • Possible duplicates: http://stackoverflow.com/questions/4675364/accessing-facebook-c-sharp-sdk-result-object-using-net-3-5-api, http://stackoverflow.com/questions/4568452/dynamic-keyword-problem – Jeremy Wiggins Jan 21 '13 at 03:12

1 Answers1

1

It would be roughly:

var auth = new CanvasAuthorizer { Perms = "user_about_me,friends_about_me" };

if (auth.Authorize())
{
    var fb = new FacebookClient(auth.Session.AccessToken);
    MyInfoType myInfo = (MyInfoType)fb.Get("/me/friends");
    foreach (var friend in myInfo.data)
    {
        Response.Write("Name: " + friend.name + "<br/>Facebook id: " + friend.id + "<br/><br/>");
    }
}

What type fb.Get returns?

Lukasz Madon
  • 14,664
  • 14
  • 64
  • 108
  • It return object. which can either be IDictionary, IList, bool, long, double or string. more info at http://stackoverflow.com/questions/7367496/dynamic-object-handle-problem-facebook-c-sharp-sdk/7369388#7369388 – prabir Jan 25 '13 at 04:37