2013-09-03 5 views
0

페이스 북에 로그온하는 웹 페이지가 있으며 모든 친구 목록이 그림과 함께 표시됩니다. 내 모든 사진을 내 서버의 zip 폴더에 다운로드하여 다운로드하고 싶습니다. 각 그림은 고유 한 ID가 있지만 순서대로 다운로드하고 이름 지정 체계 인 1.jpg, 2.jpg 등으로 이름을 바꿔야합니다.웹 페이지를로드 할 때 2000+ 이미지를 압축하는 방법

몇 가지 시도했지만 아무 것도 효과가 없었습니다. 우선 시도 :

$i = 1; 
foreach ($friends["data"] as $value) { 
$url = 'https://graph.facebook.com/' . $value["id"] . '/picture?type=large'; 
copy($url,"$i.jpg"); 
$i++; 
} 

나는이 일을 생각하지만 이미지를 열려고 할 때, 그들은 모두 0킬로바이트이-이 쉽게 다운로드 지퍼 모든 내용을 저장하지 않고 있었다.

나는 다음이 시도 :

$i=1; 
foreach ($friends["data"] as $value) { 
$fileName = '<img src="https://graph.facebook.com/' . $value["id"] . '/picture?type=large"/> <br />'; 
echo $fileName; 

header("Content-Disposition: attachment; filename='".$fileName."'"); 
$target=$fileName; 
$newName=$i.'jpg'; 
rename($target, $newName); 
$i++; 
} 

을하지만이 오류 준 :

Warning: Cannot modify header information - headers already sent by (output started at /home/xxx/public_html/xxx.com/facebooksdk/facebook-php-sdk/examples/test.php:70) in /home/xxx0/public_html/xxx.com/facebooksdk/facebook-php-sdk/examples/test.php on line 138 

Warning: rename(graph.facebook.com/xx/picture?type=large"/> <br />,1jpg) [function.rename]: No such file or directory in /home/xxx/public_html/xxx.com/facebooksdk/facebook-php-sdk/examples/test.php on line 141 

는 심지어 제대로 불구하고 작성한하지 않을 수 있습니다이 두 번째 코드는 ... 어떤 도움도 대단히 감사하겠습니다을!

$i = 1; 
    foreach ($friends["data"] as $value) { 

     echo '<img src="https://graph.facebook.com/' . $value["id"] . '/picture?type=large"/> <br />'; 
     $url = 'https://graph.facebook.com/' . $value["id"] . '/picture?type=large'; 
     $img = 'photos/'.$i.'.jpg'; 
     file_put_contents($img, file_get_contents($url)); 
     $i++; 
    } 

나는 아직 폴더를 압축하는 방법을 달려하지 않은 비록 :

+0

'copy()'호출 바로 뒤에'var_dump (error_get_last());'를 놓습니다. 그것은 무엇을 보여줍니까? –

+0

ok-will,하지만 내가 알 수있는 한, 파일 이름 만 복사하고 내용 -IE는 복사하지 않습니다. 실제로 그림을 다운로드하지 않습니다 .... – Joel

+0

정말 오랜 시간이 걸렸습니다. 전에 내 컴퓨터가 아무것도 반환했습니다. 2000 개가 넘는 이미지 루프에서 이미지 정보에 var 덤프를 수행하는 것보다 다른 방법이 있어야합니다. – Joel

답변

0

이 작동하는 것 같군.

관련 문제