我想让用户可以选择在我的drupal网站上从FB帐户上传他们的照片..
有没有drupal模块可以做到这一点? 我听说过Graph API但却无法使用它..
任何建议都将不胜感激!
答案 0 :(得分:1)
以下是PHP站点上how to access Facebook photo albums的示例。希望它可以帮到你。
<?php
require_once 'library/facebook.php';
try{
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
if(is_null($facebook->getUser()))
{
header("Location:{$facebook->getLoginUrl(array('req_perms' => 'user_status,publish_stream,user_photos'))}");
exit;
}
$me = $facebook->api('/me');
}catch(Exception $e){
echo $e->getMessage();
echo '<p>Please try clearing your browser cookies or <a href="http://demos.frnzzz.com/fbAlbum/photos.php">click here</a>.</p>';
die;
}
?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade'
});
});
</script>
<title>WebSPeaks.in | Access facebook Albums on your site using PHP</title>
</head>
<body>
<?php
$albums = $facebook->api('/me/albums');
$action = $_REQUEST['action'];
$album_id = '';
if(isset($action) && $action=='viewalbum'){
$album_id = $_REQUEST['album_id'];
$photos = $facebook->api("/{$album_id}/photos");
?>
<div class="slideshow">
<?php
foreach($photos['data'] as $photo)
{
echo "<img src='{$photo['source']}' />";
}
?>
</div>
<?php
}
$pageURL .= 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
echo '<div class="alb">';
if(strstr($pageURL,'.php?')){
$and = '&';
}else{
$and = '?';
}
echo '<p class="hd">My Albums</p>';
foreach($albums['data'] as $album)
{
if($album_id == $album['id']){
$name = '<b><u>'.$album['name'].'</u></b>';
}else{
$name = $album['name'];
}
echo '<p>'."<a href=".$pageURL.$and."action=viewalbum&album_id=".$album['id'].">".$name.'</a></p>';
}
echo '</div>';
?>
</body>
</html>