2014-11-13 2 views
0

이야기와 관련된 이미지를 가져 오려고합니다. 562348400566770 나는 그래프 API를 통해이를 실행 얻을 이미지의 배열 나는 다음과 같은 요청을하고있는 중이 야 내 페이스 북 SDK에서 다시 Facebook API - getProperty ('source') null을 반환했습니다.

을 돌아왔다 :

이미지 ID는

$request = new FacebookRequest(
    $session, 
    'GET', 
    '/'.$image.'/?fields=images' 
); 
$response = $request->execute(); 
$images = $response->getGraphObject(); 

$image_data = $images->getProperty('images'); 

나는를 또한 $의 image_data의 위해서 var_dump를하고 내가 얻을 :

object(Facebook\GraphObject)#5 (1) { 
    ["backingData":protected]=> 
    array(7) { 
    [0]=> 
    object(stdClass)#35 (3) { 
     ["height"]=> 
     int(960) 
     ["source"]=> 
     string(153) "https://scontent-a.xx.fbcdn.net/hphotos-xfa1/v/l/t1.0-9/10612975_562348400566770_442227994869299119_n.jpg?oh=3415f1e0387bd99b9afdb8a4d043f97e&oe=54E3156D" 
     ["width"]=> 
     int(720) 
    } 
    [1]=> 
    object(stdClass)#36 (3) { 
     ["height"]=> 
     int(800) 
     ["source"]=> 
     string(162) "https://scontent-a.xx.fbcdn.net/hphotos-xfa1/v/l/t1.0-9/p600x600/10612975_562348400566770_442227994869299119_n.jpg?oh=cf421a040e84c64dbdfa325ad96ced91&oe=54D38F13" 
     ["width"]=> 
     int(600) 
    } 
    [2]=> 
    object(stdClass)#37 (3) { 
     ["height"]=> 
     int(640) 
     ["source"]=> 
     string(162) "https://scontent-a.xx.fbcdn.net/hphotos-xfa1/v/l/t1.0-9/p480x480/10612975_562348400566770_442227994869299119_n.jpg?oh=99db9b6a31e4b13074676d95be9bbacb&oe=54D69A0B" 
     ["width"]=> 
     int(480) 
    } 
    [3]=> 
    object(stdClass)#38 (3) { 
     ["height"]=> 
     int(426) 
     ["source"]=> 
     string(166) "https://scontent-a.xx.fbcdn.net/hphotos-xfa1/v/l/t1.0-9/q81/p320x320/10612975_562348400566770_442227994869299119_n.jpg?oh=33959139380a717f4250bc8a186408a4&oe=55175DD7" 
     ["width"]=> 
     int(320) 
    } 
    [4]=> 
    object(stdClass)#39 (3) { 
     ["height"]=> 
     int(540) 
     ["source"]=> 
     string(166) "https://scontent-a.xx.fbcdn.net/hphotos-xfa1/v/l/t1.0-9/q81/p180x540/10612975_562348400566770_442227994869299119_n.jpg?oh=67fec7a39974a4000bbb773925be6370&oe=54D397A1" 
     ["width"]=> 
     int(405) 
    } 
    [5]=> 
    object(stdClass)#40 (3) { 
     ["height"]=> 
     int(173) 
     ["source"]=> 
     string(166) "https://scontent-a.xx.fbcdn.net/hphotos-xfa1/v/l/t1.0-9/q81/p130x130/10612975_562348400566770_442227994869299119_n.jpg?oh=d776025d9a185690d6046c0e345ec6e7&oe=54E3A447" 
     ["width"]=> 
     int(130) 
    } 
    [6]=> 
    object(stdClass)#41 (3) { 
     ["height"]=> 
     int(225) 
     ["source"]=> 
     string(165) "https://scontent-a.xx.fbcdn.net/hphotos-xfa1/v/l/t1.0-9/q81/p75x225/10612975_562348400566770_442227994869299119_n.jpg?oh=c9a4b3e8289a4df07a2fa6a2b6a894b1&oe=54E793B6" 
     ["width"]=> 
     int(168) 
    } 
    } 
} 

내 다음 단계가되는 이미지의 속성을 가져올 수

<img src="<?php echo $images->getProperty('source'); ?>" alt="<?php echo $page_name; ?>" /> 

그러나 echo $ images-> getProperty ('source'); "NULL"을 반환합니다.

내가 여기에 분명한 것을 놓치고 있습니까? 또는 이미지를 가져 오는 더 쉬운 방법이 있습니다.

미리 감사드립니다. 다른 이미지 크기에

$images = (new FacebookRequest(
$session, 'GET', '/562348400566770?fields=source' 
))->execute()->getGraphObject()->asArray(); 

echo $images['source']; 


당신이 이미지를 호출 할 수 있습니다,이 원하는 하나의 경우

답변

0

이는 '소스'필드 위의 내용을 줄 것이다

$images = (new FacebookRequest(
$session, 'GET', '//562348400566770?fields=images' 
))->execute()->getGraphObject()->asArray(); 

print_r($images); 
,745 : 다음 필드 및 배열 액세스 HTML에서


직접 전화 :

<img src="https://graph.facebook.com/562348400566770/picture" />