2011-12-15 1 views
0

나는 내가 실제 이미지 URL을 얻고 싶은 것을 할, .JPG와 실제 이미지 URL을 저장할하지만 난이 같은 URL이 - http://graph.facebook.com/543525921/pictureURL의 이미지 URL을 추출하는 방법 http://graph.facebook.com/{ANYUSERID/picture?

이 URL의 실제 이미지 URL이 https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/371089_543525921_1936288375_q.jpg

입니다

"http://graph.facebook.com/anyuserid/picture"와 같은 URL을 PHP에서 제공했을 때 실제 이미지 URL을 표시하는 방법은 무엇입니까?

나는 많이 시도했지만 실패했습니다. 좀 도와 줘서 고맙습니다. 고마워요!

+1

죄송합니다. 나는 대답을 찾았다! 다른 사람이 이런 문제가 생기면 도움이 될 것입니다 - http://stackoverflow.com/questions/3535222/get-facebook-real-profile-image-url –

+0

PHP'copy ($ url)'을 사용할 수 있습니다. 함수 (일반적으로 HTTP 프로토콜과 함께 작동). –

답변

0

여기 제가 같은 문제를 해결하기 위해 사용했던 코드가 있습니다.

$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 
    } 
} 
관련 문제