我正在尝试在灯箱(或类似的画廊类型的东西)中显示照片库,但我的客户希望照片来自 Facebook 相册,以避免不得不两次上传照片。
我在 wordpress 中工作,但我环顾了一些可用的插件,它们似乎不太有希望。
我在这里最好的进攻计划是什么?我还没有真正开始深入研究 facebook api,但如果这是你们的建议,我会继续做。我对 javascript 和 php 非常熟悉。在我确定它会起作用之前,我不想进入那个兔子洞。
我只是真的在寻找人们分享一些见解,因为我真的不知道从哪里开始。
编辑:
这就是我被困的地方......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Facebook Photo Gallery</title>
<script type='text/javascript' src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$.getJSON('http://graph.facebook.com/356611067762340/photos').then(function(response) {
// 0-8, 0 returns the largest available images, 8 the smallest
var imageIndex = 5;
var images = _(response.data)
.chain()
.pluck('images')
.pluck(imageIndex)
.value();
console.log(images);
_(images).each(function(image) {
$('#image-container').append(
$('<img>').attr('src', image.source)
);
});
});
</script>
</head>
<body>
<div id="image-container"></div>
</body>
</html>
这对我来说似乎完全有效,为什么它不起作用......?