How to get full size Profile Picture in Facebook using ASP.Net

mikehell
 
on Jan 18, 2013 12:58 AM
6334 Views

Hello,

Regarding Mudassar Ahamed Khan article about how to get user details from facebook api found here

 How do i get a bigger user picture?

the default image size is 50px X 50px (default from facebook) and i need 350px image

I saw in facebook developer help site that there is a height and width property for user_photo parameter, my question is how to use it with the snippet found in Mudassar article?

Thank you for the answer and best regards,

mike

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
on Jan 19, 2013 08:00 AM

This way

 

public partial class CS : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        FaceBookConnect.API_Key = "<API Key>";
        FaceBookConnect.API_Secret = "<API Secret>";
        if (!IsPostBack)
        {
            string code = Request.QueryString["code"];
            if (!string.IsNullOrEmpty(code))
            {
                string data = FaceBookConnect.Fetch(code, "me/albums");
                FaceBookAlbumData faceBookAlbumData = new JavaScriptSerializer().Deserialize<FaceBookAlbumData>(data);
                List<FaceBookAlbum> albums = new List<FaceBookAlbum>();
                foreach (FaceBookAlbum album in faceBookAlbumData.Data)
                {
                    if (album.Name == "Profile Pictures")
                    {
                        data = FaceBookConnect.Fetch(code, album.Id + "/photos");
                        album.Images = new JavaScriptSerializer().Deserialize<FaceBookImageData>(data).Data;
                        Image1.ImageUrl = album.Images[0].Source;
                        break;
                    }
                }
            }
        }
    }

    protected void Fetch(object sender, EventArgs e)
    {
        FaceBookConnect.Authorize("user_photos", Request.Url.AbsoluteUri.Split('?')[0]);
    }
}
public class FaceBookAlbumData
{
    public List<FaceBookAlbum> Data { get; set; }
}

public class FaceBookAlbum
{
    public string Id { get; set; }
    public string Name { get; set; }
    public List<FaceBookImage> Images { get; set; }
}

public class FaceBookImageData
{
    public List<FaceBookImage> Data { get; set; }
}

public class FaceBookImage
{
    public string Id { get; set; }
    public string Picture { get; set; }
    public string Source { get; set; }
    public int Height { get; set; }
    public int Width { get; set; }
}
 <asp:Button ID="btnFetch" runat="server" Text="Get FaceBook Pictures" OnClick="Fetch" />
    <hr />
    <asp:Image ID="Image1" runat="server" />