0

如您所知,我正在为我的网站使用 shadowbox 通过单击缩略图来打开大图像。我的问题是,我正在获取用户的 Facebook 个人资料照片,例如:

$large = "https://graph.facebook.com/{$id2}/picture?type=large";
$small = "https://graph.facebook.com/{$id2}/picture?type=square";

它工作完美,但在影子盒中我有大图像的问题..

我在 shadowbox 中这样称呼它:

<a href="<?php echo $large; ?>" rel="shadowbox">
<img style="max-width:50px; max-height:50p;" src="<?php echo $small; ?>" />
</a>

可以想象,小图像显示完美,但是当我单击具有 href 的小图像时,它无法显示大图像。

我试图将大图像变量更改为此:

$large = "https://graph.facebook.com/{$id2}/picture?type=large&redirect=false";

但它也未能显示大图像..

希望能帮到你,谢谢

4

2 回答 2

0

https://graph.facebook.com/{$id2}/picture?type=large&redirect=false基本上为您返回一个文本内容图像的 URL。这就是它不显示的原因。

例如。

https://graph.facebook.com/yungsenriady.budiman.3/picture?type=large&redirect=false

返回

"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/157348_100001167523294_1569184886_n.jpg"

尝试使用

https://graph.facebook.com/{$id2}/picture?type=large
于 2012-09-28T22:55:15.207 回答
0

我之前没有使用过 Shadowbox,所以我不知道它在幕后是如何工作的。可能是它无法处理为大图像返回另一个 url 的 url。

尝试使用 php 进行 API 调用,然后将此结果传递给 shadowbox。

$large = file_get_contents("https://graph.facebook.com/{$id2}/picture?type=large&redirect=false");

当然,file_get_contents()像这样使用是一种快速而肮脏的方法。如果可行,在将其推广到生产站点之前,您需要使用cURL或更好的Facebook PHP SDK来执行此操作。

假设您使用 shadowbox 在一个页面上显示多个用户的照片,您最终可能会在某个时候遇到 API 限制。为防止这种情况,请重做 API 调用以一次抓取多张照片:

$large_photos = $fb->api('/picture?type=large&redirect=false&ids=' . 
                           implode($ids_array, ','));
于 2012-09-29T02:43:56.690 回答