Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Facebook Graph API Load And Save Facebook Profile Picture Of User

Load And Save Facebook Profile Picture Of User

There is an easy way to display Facebook Profile Picture if you already know their Facebook ID or Username. By using Facebook Graph API, you can get your own/anyone profile picture in 2 type of sizes: default(small) and large.

This method is public so you or your users aren’t be required to allow app permission or anything. And you can load any Facebook profile picture you want as long as you know their Facebook ID or Facebook username. Note that not all Facebook users register their username therefore using Facebook ID is better.

1. Display Facebook Profile Picture of User

In order to load Profile Picture of a particular Facebook user, simply access the picture from a URL below and as I mentioned above, we can display it in 2 difference sizes: small and large.

+ Small:

http://graph.facebook.com/hoanhuynhtrong/picture
http://graph.facebook.com/1258565465/picture

http://graph.facebook.com/hoanhuynhtrong/picture http://graph.facebook.com/1258565465/picture

+ Large:

http://graph.facebook.com/hoanhuynhtrong/picture?type=large
http://graph.facebook.com/1258565465/picture?type=large

http://graph.facebook.com/hoanhuynhtrong/picture?type=large http://graph.facebook.com/1258565465/picture?type=large

Using Facebook ID or Username will return the same result and just replace my username(hoanhuynhtrong) or ID(1258565465) with the username or ID you want to display their profile picture.

2. Save Profile Picture to file

In order to save the external picture somewhere in your web server, you can use a simple ASP.NET or PHP script to do it. Below is a PHP example:

<?php
	$fid = "hoanhuynhtrong";
	$img = file_get_contents("https://graph.facebook.com/" . $fid . "/picture?type=large");
	$file = dirname(__file__). "/" . $fid . ".jpg";
	file_put_contents($file, $img);
?>

<?php $fid = "hoanhuynhtrong"; $img = file_get_contents("https://graph.facebook.com/" . $fid . "/picture?type=large"); $file = dirname(__file__). "/" . $fid . ".jpg"; file_put_contents($file, $img); ?>

Nov 7, 2011Hoan Huynh
PHP Connect To MS SQL ServerPHP Load And Save Facebook Friend List
You Might Also Like:
  • Facebook Load User Profile Via Graph API And FQL Query
  • PHP Change Facebook Profile Picture With Graph API
  • Get or Find Facebook Profile Id Number
  • PHP Load And Save Facebook Friend List
  • Make Short URL For Facebook Profile, Fan Page Or Application Page
  • PHP Load Facebook Albums And Save To MySQL Database
  • Get Or Find Facebook Fan Page Id Number
  • PHP Get Likes Number Of Facebook Page
  • Add More Extra Informations Or Fields To WordPress User Profile
  • Facebook Removed View App Profile Page link For New Apps
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

10 years ago Facebook Graph APIFacebook766
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,442 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,823 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,631 views
JQuery Allow only numeric characters or only alphabet characters in textbox
14,978 views
C# Read Json From URL And Parse/Deserialize Json
11,691 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development