try {
$requestCover = $fb->get('me?fields=cover'); //getting user Cover
$requestProfileCover=$fb->get('/me');
// $cover = $requestCover->getGraphUser();
// $profile = $requestProfileCover->getGraphUser();
}
catch(Facebook\Exceptions\FacebookResponseException $e) {
echo ' error: ' . $e->getMessage();
exit;
}
catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK error: ' . $e->getMessage();
exit;
}
print_r($requestCover); // showing cover details on the screen
echo "<img src='".$requestCover['source']."'/>";
錯誤:我試圖通過圖API獲取FACEBOOK封面,但我無法使用。
Fatal error: Uncaught Error: Cannot use object of type Facebook\FacebookResponse as array in C:\xampp\htdocs\fb_app\twibook\index.php:165 Stack trace: #0 {main} thrown in C:\xampp\htdocs\fb_app\twibook\index.php on line 165
究竟是如何不工作? –
錯誤:致命錯誤:未捕獲錯誤:無法使用Facebook \ FacebookResponse類型的對象作爲C:\ xampp \ htdocs \ fb_app \ twibook \ index.php中的數組:165堆棧跟蹤:#0 {main}拋出C:\ xampp \ htdocs \ fb_app \ twibook \ index.php 165行 –
我想165行是你的代碼片段的最後一行?嘗試訪問它通過'$ requestCover->源' – Philipp