As I see
http://graph.facebook.com/1234/picture
do redirect to:
Try to add: curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
TRUE to follow any "Location: " header that the server sends as part of the HTTP header (note this is recursive, PHP will follow as many "Location: " headers that it is sent, unless CURLOPT_MAXREDIRS is set).
So your code may looks like:
function DownloadImage($url, $dest){
$curl = curl_init($url);
$fp = fopen($dest, 'wb');
curl_setopt($curl, CURLOPT_FILE, $fp);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_exec($curl);
curl_close($curl);
fclose($fp);
}
try{
$social_id='1234';
DownloadImage('http://graph.facebook.com/'.$social_id.'/picture', '../user_image/normal/'.$social_id.'.jpg');
DownloadImage('http://graph.facebook.com/'.$social_id.'/picture?width=141&height=141', '../user_image/bigger/'.$social_id.'.jpg');
}
catch(Exception $errr){
echo $errr;
}