/
get_flickr_images.php
77 lines (62 loc) · 1.97 KB
/
get_flickr_images.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
<?php
/**
* Get images from flickr
*/
require_once('phpFlickr/phpFlickr.php');
class GetFlickrImages {
public $images = array();
public $owner;
public function __construct(){
}
/**
* get images from flickr
* @author - Henry Addo
* @access - public
* @return - Array of images
*/
public function get_images() {
$username = "";
$photo_urls = "http://www.flickr.com/photos/eyedol/";
$tags = "tedglobal2007";
// create instance of phpFlickr class
$flickr = new phpFlickr('');
//enable caching
$flickr->enableCache("");
//authenticate
//$flickr->auth();
//get token
//$token = $token['user']['nsid'];
// get NSID of the username
$nsid = $token['user']['nsid'];
$user = $flickr->people_findByUsername($username);
//get the friendly URL of the the users' photos
$photos_url = $flickr->urls_getUserPhotos( $username );
// get 20 images of public images of the user
//$photos = $flickr->photos_search( array( 'tags'=>$tags,
//'per_page'=> 200 ) );
$photos = $flickr->people_getPublicPhotos($username, NULL, 36);
// loop through the photos
foreach( (array)$photos['photo'] as $photo ) {
$this->images[] = "<li><a href=\"#\">
<img alt='$photo[title]' title='$photo[title]'
src=\"".$flickr->buildPhotoURL($photo,'Square')."\"
onclick=\"get_image_id('".
$flickr->buildPhotoURL($photo).
"','$photo[title]')\"/></a></li>";
$owner = $flickr->people_getInfo( $photo[owner] );
$this->owner = $owner['username'];
}
return $this->images;
}
/**
* get flickr owner
* @author - Henry Addo
* @access - public
* @return - owner - owner of the photos
*/
public function get_owner() {
return $this->owner;
}
}
$flickr_images = new GetFlickrImages();
?>