Calling friends profile image with GRAPH API

Asked

Viewed 359 times

-1

How do I call my friends' profile image?

Mine I can already seek this way me/picture?redirect=false.

  • Hi, Jefferson, the correct is to tag the relevant language. And also the code snippet you use to fetch your image.

  • so I use this code here to call my photo " FB.api('me/picture', Function(info_pic) { var photo=info_pic.data.url; console.log(info_pic); $("#foto1"). html("<img width=30 height=30 src=" + photo + ">"); }); " I would like to know how to call my friends randomly

  • Click [Edit] below the question to include new information and format the code correctly.

1 answer

0

Basically the command is

public ActionResult Index()
{
    if (StatusAutorizacao())
    {
        Facebook.FacebookClient client = new Facebook.FacebookClient(access_token);
        client.AppId = App_Id;
        client.AppSecret = App_Secret;
        dynamic friends = client.Get("me/friends/?fields=name,birthday,picture, gender");
        IEnumerable  listafriends = (from c in ((IEnumerable)friends.data)
                                select new
                                {
                                    Id = c.id, 
                                    Name = c.name,
                                    Birthday = c.birthday,
                                    Picture = c.picture.data.url,
                                    Sexo = c.gender
                                }).AsEnumerable();
        return View(listafriends);
    }
    else
    {
        return null;
    }
}

And at the index, you put the view

@model IEnumerable  
@{
    ViewBag.Title = "Index";
}                            

Index

@foreach (object item in Model) { Type type = item.GetType(); @String.Format("{0} {1}", type.GetProperty("Id").GetValue(item,null).ToString(), type.GetProperty("Name").GetValue(item,null).ToString()) }
  • Sorry I forgot to specify that I am using javascript ;(

Browser other questions tagged

You are not signed in. Login or sign up in order to post.