flickr-fotoalbum
================
flickr.inc.php
================
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Contact the Flickr photo API
*
* @author Boaz den Besten
* @version 1.1.15-4-2007
* @contact www.n3rd.nl
* @PHPversion: 5+
*/
class clsFlickr{
/**
* You API key
*
* @var String API key
*/
private $sAPIKey = '';
/**
* Method requests are handled by Flickr
*
* @var String format
*/
const FORMAT = 'php_serial';
/**
* Constructor
*
* @param String API Key (Optional)
*/
public function __construct($p_sAPIKey=null){
if(!is_null($p_sAPIKey)){
$this->sAPIKey = $p_sAPIKey;
}
}
/**
* Change the used API Key
*
* @param String API Key
*/
public function setAPIKey($p_sAPIKey){
$this->sAPIKey = $p_sAPIKey;
}
/**
* Call a Flickr API method
*
* @param String Method Name (example: flickr.people.getPublicPhotos)
* @param Array Method arguments
* @return Array Flickr response
*/
public function call($p_sFlickrApiMethod, $p_aArguments=array()){
$aReturn = null;
$aParams[] = 'api_key='.$this->sAPIKey;
$aParams[] = 'method='.$p_sFlickrApiMethod;
$aParams[] = 'format='.self::FORMAT;
foreach($p_aArguments as $sKey => $sValue){
$aParams[] = urlencode($sKey).'='.urlencode($sValue);
}
$sURL = "http://api.flickr.com/services/rest/?".implode('&', $aParams);
$sRsp = file_get_contents($sURL);
$aReturn = unserialize($sRsp);
// Als de request mislukt is:
if($aReturn['stat'] != 'ok'){
throw new Exception($aReturn['message'], $aReturn['code']);
}
// Als de request gelukt is:
return $aReturn;
}
}
?>
/**
* Contact the Flickr photo API
*
* @author Boaz den Besten
* @version 1.1.15-4-2007
* @contact www.n3rd.nl
* @PHPversion: 5+
*/
class clsFlickr{
/**
* You API key
*
* @var String API key
*/
private $sAPIKey = '';
/**
* Method requests are handled by Flickr
*
* @var String format
*/
const FORMAT = 'php_serial';
/**
* Constructor
*
* @param String API Key (Optional)
*/
public function __construct($p_sAPIKey=null){
if(!is_null($p_sAPIKey)){
$this->sAPIKey = $p_sAPIKey;
}
}
/**
* Change the used API Key
*
* @param String API Key
*/
public function setAPIKey($p_sAPIKey){
$this->sAPIKey = $p_sAPIKey;
}
/**
* Call a Flickr API method
*
* @param String Method Name (example: flickr.people.getPublicPhotos)
* @param Array Method arguments
* @return Array Flickr response
*/
public function call($p_sFlickrApiMethod, $p_aArguments=array()){
$aReturn = null;
$aParams[] = 'api_key='.$this->sAPIKey;
$aParams[] = 'method='.$p_sFlickrApiMethod;
$aParams[] = 'format='.self::FORMAT;
foreach($p_aArguments as $sKey => $sValue){
$aParams[] = urlencode($sKey).'='.urlencode($sValue);
}
$sURL = "http://api.flickr.com/services/rest/?".implode('&', $aParams);
$sRsp = file_get_contents($sURL);
$aReturn = unserialize($sRsp);
// Als de request mislukt is:
if($aReturn['stat'] != 'ok'){
throw new Exception($aReturn['message'], $aReturn['code']);
}
// Als de request gelukt is:
return $aReturn;
}
}
?>
================
photosets.php
================
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Photosets</title>
<style type="text/css">
@import url('photos.css');
</style>
</head>
<body>
<?php
require_once 'flickr.inc.php';
$oFlickr = new clsFlickr();
$oRsp = $oFlickr->call('flickr.photosets.getList', array('user_id' => '7750512@N08'));
echo '<div id="photos">';
foreach($oRsp['photosets']['photoset'] as $aPhotoset){
$sThumb = 'http://farm'.$aPhotoset['farm'].'.static.flickr.com/'.$aPhotoset['server'].'/'.$aPhotoset['primary'].'_'.$aPhotoset['secret'].'_s.jpg';
echo '<div class="album">';
echo '<a href="photoset.php?id='.$aPhotoset['id'].'"><img alt="'.$aPhotoset['title']['_content'].'" title="'.$aPhotoset['title']['_content'].'" src="'.$sThumb.'"></a>';
echo '<small>'.$aPhotoset['title']['_content'].'</small>';
echo '<br><small>'.$aPhotoset['photos'].' Photos</small>';
echo '</div>';
}
echo '</div>';
?>
</body>
</html>
<html>
<head>
<title>Photosets</title>
<style type="text/css">
@import url('photos.css');
</style>
</head>
<body>
<?php
require_once 'flickr.inc.php';
$oFlickr = new clsFlickr();
$oRsp = $oFlickr->call('flickr.photosets.getList', array('user_id' => '7750512@N08'));
echo '<div id="photos">';
foreach($oRsp['photosets']['photoset'] as $aPhotoset){
$sThumb = 'http://farm'.$aPhotoset['farm'].'.static.flickr.com/'.$aPhotoset['server'].'/'.$aPhotoset['primary'].'_'.$aPhotoset['secret'].'_s.jpg';
echo '<div class="album">';
echo '<a href="photoset.php?id='.$aPhotoset['id'].'"><img alt="'.$aPhotoset['title']['_content'].'" title="'.$aPhotoset['title']['_content'].'" src="'.$sThumb.'"></a>';
echo '<small>'.$aPhotoset['title']['_content'].'</small>';
echo '<br><small>'.$aPhotoset['photos'].' Photos</small>';
echo '</div>';
}
echo '</div>';
?>
</body>
</html>
================
photoset.php
================
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Photoset</title>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<style type="text/css">
@import url('photos.css');
</style>
</head>
<body>
<?php
require_once 'flickr.inc.php';
$oFlickr = new clsFlickr();
$per_page = 20;
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
$photoset_id = !empty($_GET['id']) ? $_GET['id'] : header('Location: photosets.php');
$oRsp = $oFlickr->call('flickr.photosets.getPhotos', array('photoset_id' => $photoset_id, 'page' => $page, 'per_page' => $per_page));
echo '<div id="photos">';
echo '<p class="back">< <a href="photosets.php">View all sets</a></p>';
foreach($oRsp['photoset']['photo'] as $aPhoto){
$sThumb = 'http://farm'.$aPhoto['farm'].'.static.flickr.com/'.$aPhoto['server'].'/'.$aPhoto['id'].'_'.$aPhoto['secret'].'_t.jpg';
$sBig = 'http://farm'.$aPhoto['farm'].'.static.flickr.com/'.$aPhoto['server'].'/'.$aPhoto['id'].'_'.$aPhoto['secret'].'.jpg';
echo '<a class="img" href="'.$sBig.'" rel="lightbox[myphotos]" title="'.$aPhoto['title'].'"><img alt="'.$aPhoto['title'].'" title="'.$aPhoto['title'].'" src="'.$sThumb.'"></a>';
}
if($oRsp['photoset']['pages'] > 1){
echo '<p class="pagenumbers"><span>Page:</span> ';
for($i=1;$i<=$oRsp['photoset']['pages'];$i++){
echo '<a href="?id='.$photoset_id.'&page='.$i.'" '.($i == $page ? 'class="active"' : '').'>'.$i.'</a>';
}
echo '</p>';
}
echo '</div>';
?>
</body>
</html>
<html>
<head>
<title>Photoset</title>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<style type="text/css">
@import url('photos.css');
</style>
</head>
<body>
<?php
require_once 'flickr.inc.php';
$oFlickr = new clsFlickr();
$per_page = 20;
$page = !empty($_GET['page']) ? $_GET['page'] : 1;
$photoset_id = !empty($_GET['id']) ? $_GET['id'] : header('Location: photosets.php');
$oRsp = $oFlickr->call('flickr.photosets.getPhotos', array('photoset_id' => $photoset_id, 'page' => $page, 'per_page' => $per_page));
echo '<div id="photos">';
echo '<p class="back">< <a href="photosets.php">View all sets</a></p>';
foreach($oRsp['photoset']['photo'] as $aPhoto){
$sThumb = 'http://farm'.$aPhoto['farm'].'.static.flickr.com/'.$aPhoto['server'].'/'.$aPhoto['id'].'_'.$aPhoto['secret'].'_t.jpg';
$sBig = 'http://farm'.$aPhoto['farm'].'.static.flickr.com/'.$aPhoto['server'].'/'.$aPhoto['id'].'_'.$aPhoto['secret'].'.jpg';
echo '<a class="img" href="'.$sBig.'" rel="lightbox[myphotos]" title="'.$aPhoto['title'].'"><img alt="'.$aPhoto['title'].'" title="'.$aPhoto['title'].'" src="'.$sThumb.'"></a>';
}
if($oRsp['photoset']['pages'] > 1){
echo '<p class="pagenumbers"><span>Page:</span> ';
for($i=1;$i<=$oRsp['photoset']['pages'];$i++){
echo '<a href="?id='.$photoset_id.'&page='.$i.'" '.($i == $page ? 'class="active"' : '').'>'.$i.'</a>';
}
echo '</p>';
}
echo '</div>';
?>
</body>
</html>
================
photos.css
================
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
div#photos *{
font-family: Verdana, sans-serif;
}
/**
* Single Set
*/
div#photos p.back{
font-size: 11px;
}
div#photos p.back a{
color: black;
}
div#photos a.img{
margin: 10px;
}
div#photos img{
border: 0;
}
div#photos p.pagenumbers span{
margin-top: 5px;
font-size: 12px;
float: left;
}
div#photos p.pagenumbers a{
display: block;
float: left;
text-align: center;
font-size: 12px;
margin: 3px;
padding: 3px 5px 3px 5px;
border: 1px solid black;
color: black;
}
div#photos p.pagenumbers a:hover, div#photos p.pagenumbers a.active{
border: 1px solid silver;
color: silver;
}
/**
* Sets Overview
*/
div#photos div.album{
margin:10px;
padding: 5px;
padding-bottom: 20px;
padding-top: 10px;
border: 1px solid silver;
border-bottom: 2px solid black;
border-left: 2px solid black;
width:95px;
text-align: center;
float: left;
}
div#photos div.album img{
border: 0;
}
div#photos div.album small{
font-size: 9px;
display: block;
}
font-family: Verdana, sans-serif;
}
/**
* Single Set
*/
div#photos p.back{
font-size: 11px;
}
div#photos p.back a{
color: black;
}
div#photos a.img{
margin: 10px;
}
div#photos img{
border: 0;
}
div#photos p.pagenumbers span{
margin-top: 5px;
font-size: 12px;
float: left;
}
div#photos p.pagenumbers a{
display: block;
float: left;
text-align: center;
font-size: 12px;
margin: 3px;
padding: 3px 5px 3px 5px;
border: 1px solid black;
color: black;
}
div#photos p.pagenumbers a:hover, div#photos p.pagenumbers a.active{
border: 1px solid silver;
color: silver;
}
/**
* Sets Overview
*/
div#photos div.album{
margin:10px;
padding: 5px;
padding-bottom: 20px;
padding-top: 10px;
border: 1px solid silver;
border-bottom: 2px solid black;
border-left: 2px solid black;
width:95px;
text-align: center;
float: left;
}
div#photos div.album img{
border: 0;
}
div#photos div.album small{
font-size: 9px;
display: block;
}