0

这可能是一个愚蠢的错误,但我因此而分裂:(

语言:PHP 5.4.7 \n 框架:CodeIgniter 2.1.3,SDK:Facebook PHP SDK 3.2.2

请考虑以下控制器功能:-

public function index()
{
  //  $this->__construct();
    $data['profile'] = $this->_facebook->api('/me?fields=id');
    $this->load->view('user_profile',$data);
}

以及相应的视图(user_profile.php):-

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Showing the user profile</title>
</head>
<body>

<?php
//echo print_r($user_profile,TRUE);
echo '<IMG SRC="http://graph.facebook.com/'. $profile['id'] . '/picture" HEIGHT=32 WIDTH=32 /> ';
?>
</body>
</html>

上面的代码在 Internet Explorer 中显示了个人资料图片,但在 Chrome 中页面是空白的。在查看页面源时,它是空白的。

4

1 回答 1

1

我将从编写更简洁的 html 开始。

<img src="http://graph.facebook.com/<?php echo $profile['id']; ?>/picture" alt="Profile Photo" height="32" width="32" />

不要大写标签,img 需要 alt 属性。我总是引用属性值,即使它们是数字。

于 2013-06-06T20:07:21.370 回答