curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
function curl_redir_exec($ch)
{
static $curl_loops = 0;
static $curl_max_loops = 20;
if ($curl_loops++ >= $curl_max_loops)
{
$curl_loops = 0;
return FALSE;
}
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
@list($header, $data) = @explode("\n\n", $data, 2);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_code == 301 || $http_code == 302)
{
$matches = array();
preg_match('/Location:(.*?)\n/', $header, $matches);
$url = @parse_url(trim(array_pop($matches)));
if (!$url)
{
//couldn't process the url to redirect to
$curl_loops = 0;
return $data;
}
$last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
if (!$url['scheme'])
$url['scheme'] = $last_url['scheme'];
if (!$url['host'])
$url['host'] = $last_url['host'];
if (!$url['path'])
$url['path'] = $last_url['path'];
$new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (@$url['query']?'?'.$url['query']:'');
return $new_url;
} else {
$curl_loops=0;
return $data;
}
}
function get_right_url($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
return curl_redir_exec($curl);
}
$url = 'http://graph.facebook.com/' . $fbid . '/picture?type=large';
$file_handler = fopen('img/avatar/'.$fbid.'.jpg', 'w');
$curl = curl_init(get_right_url($url));
curl_setopt($curl, CURLOPT_FILE, $file_handler);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_exec($curl);
curl_close($curl);
fclose($file_handler);
나는 페이스 북의 저작권 정책에 대한 전문가는 아니지만, 그러나 이것은 (당신은 또한 사용자 요청해야 및/또는 여부)를 T & 고사 내에서 허용되는 경우는 확인 가치가있을 수도 있습니다. – ChrisW
Facebook에서는 user_profile의 정보와 같이 공개적으로 사용할 수있는 정보로 원하는 작업을 수행 할 수 있습니다. 또한 이러한 타사 서비스를 다운로드하거나 사용할 때 사용자 이름이나 사용자 ID가 포함 된 공개 프로필에 액세스 할 수 있습니다 , 연령대 및 국가/언어, 친구 목록, 그리고 귀하가 그들과 공유하는 모든 정보가 포함됩니다. 이러한 앱, 웹 사이트 또는 통합 서비스에서 수집 한 정보는 자체 약관 및 정책의 적용을받습니다. '이 정보는 어떻게 공유됩니까?'섹션의 https://www.facebook.com/policy.php – Simon