Skip to content


Source for "Interestingness"

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
<?php
require_once("phpFlickr/phpFlickr.php");
// Create new phpFlickr object
$f = new phpFlickr("[API Key]");
$f->enableCache(
    "db",
    "mysql://[username]:[password]@[server]/[database]"
);
 
$person = $f->people_findByUsername("Dan Coulter");
 
echo "<p>My most interesting:<br>\n";
// Search for most interesting by user_id (in this case, mine)
$photos_mine = $f->photos_search(array("user_id"=>$person['id'], "sort"=>"interestingness-desc", "per_page"=>6));
foreach ((array)$photos_mine['photo'] as $photo) {
    // Build image and link tags for each photo
    echo "<a href=http://www.flickr.com/photos/$photo[owner]/$photo[id]>";
    echo "<img border='0' alt='$photo[title]' ".
        "src=" . $f->buildPhotoURL($photo, "Square") . ">";
    echo "</a>";
}
echo "</p>\n";
 
echo "<p>Most interesting photos tagged with \"red\":<br>\n";
// Search by the single tag "red"
$photos_red = $f->photos_search(array("tags"=>"red", "sort"=>"interestingness-desc", "per_page"=>6));
foreach ((array)$photos_red['photo'] as $photo) {
    // Build image and link tags for each photo
    echo "<a href=http://www.flickr.com/photos/$photo[owner]/$photo[id]>";
    echo "<img border='0' alt='$photo[title]' ".
        "src=" . $f->buildPhotoURL($photo, "Square") . ">";
    echo "</a>";
}
echo "</p>\n";
 
echo "<p>Most interesting in a full text search for \"cat\":<br>\n";
// Search for most interesting photos with the text "cat"
$photos_cat = $f->photos_search(array("text"=>"cat", "sort"=>"interestingness-desc", "per_page"=>6));
foreach ((array)$photos_cat['photo'] as $photo) {
    // Build image and link tags for each photo
    echo "<a href=http://www.flickr.com/photos/$photo[owner]/$photo[id]>";
    echo "<img border='0' alt='$photo[title]' ".
        "src=" . $f->buildPhotoURL($photo, "Square") . ">";
    echo "</a>";
}
echo "</p>\n";
 
echo "<p>Most interesting photos today:<br>\n";
// Search for most interesting photos of today
$photos_interesting = $f->interestingness_getList(NULL, NULL, 6);
foreach ((array)$photos_interesting['photo'] as $photo) {
    // Build image and link tags for each photo
    echo "<a href=http://www.flickr.com/photos/$photo[owner]/$photo[id]>";
    echo "<img border='0' alt='$photo[title]' ".
        "src=" . $f->buildPhotoURL($photo, "Square") . ">";
    echo "</a>";
}
echo "</p>\n";
 
 
?>

2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Bucky Schwarz says

    Great API!! Thanks for making it, and thanks for taking the time to show examples.

    ReplyReply
  2. MuMe says

    Thanks for the great API!

    ReplyReply



Some HTML is OK

or, reply to this post via trackback.