0

I want to save the the real image url with .jpg ,to do that i want to get the real image url but i have a url like this - http://graph.facebook.com/543525921/picture

the real image url of this url is https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/371089_543525921_1936288375_q.jpg

How to display the real image URL always when i gave a url like "http://graph.facebook.com/anyuserid/picture" with php?

i tried alot but i failed..better some one if help me..thank you!

Naveen Gamage
  • 25
  • 1
  • 3
  • 1
    Sorry! I found the answer! if anyother one got a matter like this , this may help you - http://stackoverflow.com/questions/3535222/get-facebook-real-profile-image-url – Naveen Gamage Dec 15 '11 at 08:08
  • You could use the PHP `copy($url)` function (which usually works with HTTP protocol). – Eduard Luca Dec 15 '11 at 13:42

1 Answers1

0

Just ran into the same issue here is the code I used to solve.

$url = 'http://graph.facebook.com/' . $userInfo['id'] . '/picture?type=large';

$headers = get_headers($url, 1); // make link request and wait for redirection

if(isset($headers['Location'])) {
   $url = $headers['Location']; // this gets the new url
} else {
   $url = false; 
}

$targetPath = $_SERVER['DOCUMENT_ROOT'] . "/yourImagePath/");
$destFile = "yourFileName.jpg"

if($url){
   if (copy($url, $targetPath.$destFile)) {
   // file is now copied to your server do what ever you want here
   }
}