forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flickrlib.php
1153 lines (1007 loc) · 51 KB
/
flickrlib.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* phpFlickr Class 2.2.0
* Written by Dan Coulter ([email protected])
* Sourceforge Project Page: {@link http://www.sourceforge.net/projects/phpflickr/}
* Released under GNU Lesser General Public License ({@link http://www.gnu.org/copyleft/lgpl.html})
* For more information about the class and upcoming tools and toys using it,
* visit {@link http://www.phpflickr.com/} or {@link http://phpflickr.sourceforge.net}
*
* For installation instructions, open the README.txt file packaged with this
* class. If you don't have a copy, you can see it at:
* {@link http://www.phpflickr.com/README.txt}
*
* Please submit all problems or questions to the Help Forum on my project page:
* {@link http://sourceforge.net/forum/forum.php?forum_id=469652}
*
* Modified by Dongsheng Cai <[email protected]>
* ChangeLog:
* 1. Remove PEAR HTTP LIB, use curl.class.php (created by myself)
* 2. Remove PEAR DB LIB
* 3. Remove all cache code, it will implement in curl class.
* 4. Clean up session code
*
* Modified by David Mudrak <[email protected]>
* ChangeLog:
* 1. upload() method uses Moodle stored_file
* 2. upload() method supports all params provided by http://www.flickr.com/services/api/upload.api.html
*
* @package moodlecore
* @subpackage 3rd-party
*/
/**
* Flickr Class
* @package moodlecore
* @subpackage 3rd-party
*/
class phpFlickr {
var $api_key;
var $secret;
var $REST = 'http://api.flickr.com/services/rest/';
var $Upload = 'http://api.flickr.com/services/upload/';
var $Replace = 'http://api.flickr.com/services/replace/';
var $req;
var $response;
var $parsed_response;
var $die_on_error;
var $error_code;
var $error_msg;
var $token;
var $php_version;
/**
* When your database cache table hits this many rows, a cleanup
* will occur to get rid of all of the old rows and cleanup the
* garbage in the table. For most personal apps, 1000 rows should
* be more than enough. If your site gets hit by a lot of traffic
* or you have a lot of disk space to spare, bump this number up.
* You should try to set it high enough that the cleanup only
* happens every once in a while, so this will depend on the growth
* of your table.
*
* @global object
*/
function __construct ($api_key, $secret = NULL, $token = '')
{
global $CFG;
//The API Key must be set before any calls can be made. You can
//get your own at http://www.flickr.com/services/api/misc.api_keys.html
$this->api_key = $api_key;
$this->secret = $secret;
$this->die_on_error = false;
$this->service = "flickr";
$this->token = $token;
//Find the PHP version and store it for future reference
$this->php_version = explode("-", phpversion());
$this->php_version = explode(".", $this->php_version[0]);
$this->curl = new curl(array('cache'=>true, 'module_cache'=>'repository'));
}
function request ($command, $args = array())
{
//Sends a request to Flickr's REST endpoint via POST.
if (substr($command,0,7) != "flickr.") {
$command = "flickr." . $command;
}
//Process arguments, including method and login data.
if ($command == 'flickr.upload') {
$photo = $args['photo'];
if (empty($args['is_public'])) {
$args['is_public'] = 0;
}
if (empty($args['is_friend'])) {
$args['is_friend'] = 0;
}
if (empty($args['is_family'])) {
$args['is_family'] = 0;
}
if (empty($args['hidden'])) {
$args['hidden'] = 1;
}
$args = array("api_key" => $this->api_key,
"title" => $args['title'],
"description" => $args['description'],
"tags" => $args['tags'],
"is_public" => $args['is_public'],
"is_friend" => $args['is_friend'],
"is_family" => $args['is_family'],
"safety_level" => $args['safety_level'],
"content_type" => $args['content_type'],
"hidden" => $args['hidden']);
} else {
$args = array_merge(array("method" => $command, "format" => "php_serial", "api_key" => $this->api_key), $args);
}
if (!empty($this->token)) {
$args = array_merge($args, array("auth_token" => $this->token));
}
ksort($args);
$auth_sig = "";
foreach ($args as $key => $data) {
$auth_sig .= $key . $data;
}
if (!empty($this->secret)) {
$api_sig = md5($this->secret . $auth_sig);
$args['api_sig'] = $api_sig;
}
//$this->req->addHeader("Connection", "Keep-Alive");
if ($command != 'flickr.upload') {
$ret = $this->curl->post($this->REST, $args);
$this->parsed_response = $this->clean_text_nodes(unserialize($ret));
} else {
$args['photo'] = $photo;
$xml = simplexml_load_string($this->curl->post($this->Upload, $args));
if ($xml['stat'] == 'fail') {
$this->parsed_response = array('stat' => (string) $xml['stat'], 'code' => (int) $xml->err['code'], 'message' => (string) $xml->err['msg']);
} elseif ($xml['stat'] == 'ok') {
$this->parsed_response = array('stat' => (string) $xml['stat'], 'photoid' => (int) $xml->photoid);
$this->response = true;
}
}
if ($this->parsed_response['stat'] == 'fail') {
if ($this->die_on_error) die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
else {
$this->error_code = $this->parsed_response['code'];
$this->error_msg = $this->parsed_response['message'];
$this->parsed_response = false;
}
} else {
$this->error_code = false;
$this->error_msg = false;
}
return $this->response;
}
function clean_text_nodes($arr) {
if (!is_array($arr)) {
return $arr;
} elseif (count($arr) == 0) {
return $arr;
} elseif (count($arr) == 1 && array_key_exists('_content', $arr)) {
return $arr['_content'];
} else {
foreach ($arr as $key => $element) {
$arr[$key] = $this->clean_text_nodes($element);
}
return($arr);
}
}
function setToken($token)
{
// Sets an authentication token to use instead of the session variable
$this->token = $token;
}
function setProxy($server, $port)
{
// Sets the proxy for all phpFlickr calls.
//$this->req->setProxy($server, $port);
}
function getErrorCode()
{
// Returns the error code of the last call. If the last call did not
// return an error. This will return a false boolean.
return $this->error_code;
}
function getErrorMsg()
{
// Returns the error message of the last call. If the last call did not
// return an error. This will return a false boolean.
return $this->error_msg;
}
/** These functions are front ends for the flickr calls */
function buildPhotoURL ($photo, $size = "Medium")
{
//receives an array (can use the individual photo data returned
//from an API call) and returns a URL (doesn't mean that the
//file size exists)
$sizes = array(
"square" => "_s",
"thumbnail" => "_t",
"small" => "_m",
"medium" => "",
"large" => "_b",
"original" => "_o"
);
$size = strtolower($size);
if (!array_key_exists($size, $sizes)) {
$size = "medium";
}
if ($size == "original") {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['originalsecret'] . "_o" . "." . $photo['originalformat'];
} else {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes[$size] . ".jpg";
}
return $url;
}
function getFriendlyGeodata($lat, $lon) {
/** I've added this method to get the friendly geodata (i.e. 'in New York, NY') that the
* website provides, but isn't available in the API. I'm providing this service as long
* as it doesn't flood my server with requests and crash it all the time.
*/
return unserialize(file_get_contents('http://phpflickr.com/geodata/?format=php&lat=' . $lat . '&lon=' . $lon));
}
function auth ($perms = "write", $remember_uri = true)
{
global $FULLME;
// Redirects to Flickr's authentication piece if there is no valid token.
// If remember_uri is set to false, the callback script (included) will
// redirect to its default page.
if ($remember_uri) {
$redirect = $FULLME;
}
$api_sig = md5($this->secret . "api_key" . $this->api_key . "perms" . $perms);
$url = 'http://www.flickr.com/services/auth/?api_key=' . $this->api_key . "&perms=" . $perms . '&api_sig='. $api_sig;
return $url;
}
/**
* To use the phpFlickr::call method, pass a string containing the API method you want
* to use and an associative array of arguments. For example:
* $result = $f->call("flickr.photos.comments.getList", array("photo_id"=>'34952612'));
* This method will allow you to make calls to arbitrary methods that haven't been
* implemented in phpFlickr yet.
*/
function call($method, $arguments)
{
$this->request($method, $arguments);
return $this->parsed_response ? $this->parsed_response : false;
}
/**
* These functions are the direct implementations of flickr calls.
* For method documentation, including arguments, visit the address
* included in a comment in the function.
*/
/** Activity methods */
function activity_userComments ($per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.activity.userComments.html */
$this->request('flickr.activity.userComments', array("per_page" => $per_page, "page" => $page));
return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
}
function activity_userPhotos ($timeframe = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.activity.userPhotos.html */
$this->request('flickr.activity.userPhotos', array("timeframe" => $timeframe, "per_page" => $per_page, "page" => $page));
return $this->parsed_response ? $this->parsed_response['items']['item'] : false;
}
/** Authentication methods */
function auth_checkToken ()
{
/** http://www.flickr.com/services/api/flickr.auth.checkToken.html */
$this->request('flickr.auth.checkToken');
return $this->parsed_response ? $this->parsed_response['auth'] : false;
}
function auth_getFrob ()
{
/** http://www.flickr.com/services/api/flickr.auth.getFrob.html */
$this->request('flickr.auth.getFrob');
return $this->parsed_response ? $this->parsed_response['frob'] : false;
}
function auth_getFullToken ($mini_token)
{
/** http://www.flickr.com/services/api/flickr.auth.getFullToken.html */
$this->request('flickr.auth.getFullToken', array('mini_token'=>$mini_token));
return $this->parsed_response ? $this->parsed_response['auth'] : false;
}
function auth_getToken ($frob)
{
/** http://www.flickr.com/services/api/flickr.auth.getToken.html */
$this->request('flickr.auth.getToken', array('frob'=>$frob));
$this->token = $this->parsed_response['auth']['token'];
return $this->parsed_response ? $this->parsed_response['auth'] : false;
}
/** Blogs methods */
function blogs_getList ()
{
/** http://www.flickr.com/services/api/flickr.blogs.getList.html */
$this->request('flickr.blogs.getList');
return $this->parsed_response ? $this->parsed_response['blogs']['blog'] : false;
}
function blogs_postPhoto($blog_id, $photo_id, $title, $description, $blog_password = NULL)
{
/** http://www.flickr.com/services/api/flickr.blogs.postPhoto.html */
$this->request('flickr.blogs.postPhoto', array('blog_id'=>$blog_id, 'photo_id'=>$photo_id, 'title'=>$title, 'description'=>$description, 'blog_password'=>$blog_password), TRUE);
return $this->parsed_response ? true : false;
}
/** Contacts Methods */
function contacts_getList ($filter = NULL, $page = NULL, $per_page = NULL)
{
/** http://www.flickr.com/services/api/flickr.contacts.getList.html */
$this->request('flickr.contacts.getList', array('filter'=>$filter, 'page'=>$page, 'per_page'=>$per_page));
return $this->parsed_response ? $this->parsed_response['contacts'] : false;
}
function contacts_getPublicList($user_id, $page = NULL, $per_page = NULL)
{
/** http://www.flickr.com/services/api/flickr.contacts.getPublicList.html */
$this->request('flickr.contacts.getPublicList', array('user_id'=>$user_id, 'page'=>$page, 'per_page'=>$per_page));
return $this->parsed_response ? $this->parsed_response['contacts'] : false;
}
/** Favorites Methods */
function favorites_add ($photo_id)
{
/** http://www.flickr.com/services/api/flickr.favorites.add.html */
$this->request('flickr.favorites.add', array('photo_id'=>$photo_id), TRUE);
return $this->parsed_response ? true : false;
}
function favorites_getList($user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.favorites.getList.html */
if (is_array($extras)) { $extras = implode(",", $extras); }
$this->request("flickr.favorites.getList", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function favorites_getPublicList($user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.favorites.getPublicList.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.favorites.getPublicList", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function favorites_remove($photo_id)
{
/** http://www.flickr.com/services/api/flickr.favorites.remove.html */
$this->request("flickr.favorites.remove", array("photo_id"=>$photo_id), TRUE);
return $this->parsed_response ? true : false;
}
/** Groups Methods */
function groups_browse ($cat_id = NULL)
{
/** http://www.flickr.com/services/api/flickr.groups.browse.html */
$this->request("flickr.groups.browse", array("cat_id"=>$cat_id));
return $this->parsed_response ? $this->parsed_response['category'] : false;
}
function groups_getInfo ($group_id)
{
/** http://www.flickr.com/services/api/flickr.groups.getInfo.html */
$this->request("flickr.groups.getInfo", array("group_id"=>$group_id));
return $this->parsed_response ? $this->parsed_response['group'] : false;
}
function groups_search ($text, $per_page=NULL, $page=NULL)
{
/** http://www.flickr.com/services/api/flickr.groups.search.html */
$this->request("flickr.groups.search", array("text"=>$text,"per_page"=>$per_page,"page"=>$page));
return $this->parsed_response ? $this->parsed_response['groups'] : false;
}
/** Groups Pools Methods */
function groups_pools_add ($photo_id, $group_id)
{
/** http://www.flickr.com/services/api/flickr.groups.pools.add.html */
$this->request("flickr.groups.pools.add", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
return $this->parsed_response ? true : false;
}
function groups_pools_getContext ($photo_id, $group_id)
{
/** http://www.flickr.com/services/api/flickr.groups.pools.getContext.html */
$this->request("flickr.groups.pools.getContext", array("photo_id"=>$photo_id, "group_id"=>$group_id));
return $this->parsed_response ? $this->parsed_response : false;
}
function groups_pools_getGroups ($page = NULL, $per_page = NULL)
{
/** http://www.flickr.com/services/api/flickr.groups.pools.getGroups.html */
$this->request("flickr.groups.pools.getGroups", array('page'=>$page, 'per_page'=>$per_page));
return $this->parsed_response ? $this->parsed_response['groups'] : false;
}
function groups_pools_getPhotos ($group_id, $tags = NULL, $user_id = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.groups.pools.getPhotos", array("group_id"=>$group_id, "tags"=>$tags, "user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function groups_pools_remove ($photo_id, $group_id)
{
/** http://www.flickr.com/services/api/flickr.groups.pools.remove.html */
$this->request("flickr.groups.pools.remove", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
return $this->parsed_response ? true : false;
}
/** Interestingness methods */
function interestingness_getList($date = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.interestingness.getList.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.interestingness.getList", array("date"=>$date, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
/** People methods */
function people_findByEmail ($find_email)
{
/** http://www.flickr.com/services/api/flickr.people.findByEmail.html */
$this->request("flickr.people.findByEmail", array("find_email"=>$find_email));
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
function people_findByUsername ($username)
{
/** http://www.flickr.com/services/api/flickr.people.findByUsername.html */
$this->request("flickr.people.findByUsername", array("username"=>$username));
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
function people_getInfo($user_id)
{
/** http://www.flickr.com/services/api/flickr.people.getInfo.html */
$this->request("flickr.people.getInfo", array("user_id"=>$user_id));
return $this->parsed_response ? $this->parsed_response['person'] : false;
}
function people_getPublicGroups($user_id)
{
/** http://www.flickr.com/services/api/flickr.people.getPublicGroups.html */
$this->request("flickr.people.getPublicGroups", array("user_id"=>$user_id));
return $this->parsed_response ? $this->parsed_response['groups']['group'] : false;
}
function people_getPublicPhotos($user_id, $extras = NULL, $per_page = NULL, $page = NULL) {
/** http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.people.getPublicPhotos", array("user_id"=>$user_id, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function people_getUploadStatus()
{
/** http://www.flickr.com/services/api/flickr.people.getUploadStatus.html */
/** Requires Authentication */
$this->request("flickr.people.getUploadStatus");
return $this->parsed_response ? $this->parsed_response['user'] : false;
}
/** Photos Methods */
function photos_addTags ($photo_id, $tags)
{
/** http://www.flickr.com/services/api/flickr.photos.addTags.html */
$this->request("flickr.photos.addTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE);
return $this->parsed_response ? true : false;
}
function photos_delete($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.delete.html */
$this->request("flickr.photos.delete", array("photo_id"=>$photo_id), TRUE);
return $this->parsed_response ? true : false;
}
function photos_getAllContexts ($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.getAllContexts.html */
$this->request("flickr.photos.getAllContexts", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response : false;
}
function photos_getContactsPhotos ($count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html */
$this->request("flickr.photos.getContactsPhotos", array("count"=>$count, "just_friends"=>$just_friends, "single_photo"=>$single_photo, "include_self"=>$include_self, "extras"=>$extras));
return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
}
function photos_getContactsPublicPhotos ($user_id, $count = NULL, $just_friends = NULL, $single_photo = NULL, $include_self = NULL, $extras = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html */
$this->request("flickr.photos.getContactsPublicPhotos", array("user_id"=>$user_id, "count"=>$count, "just_friends"=>$just_friends, "single_photo"=>$single_photo, "include_self"=>$include_self, "extras"=>$extras));
return $this->parsed_response ? $this->parsed_response['photos']['photo'] : false;
}
function photos_getContext ($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.getContext.html */
$this->request("flickr.photos.getContext", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response : false;
}
function photos_getCounts ($dates = NULL, $taken_dates = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getCounts.html */
$this->request("flickr.photos.getCounts", array("dates"=>$dates, "taken_dates"=>$taken_dates));
return $this->parsed_response ? $this->parsed_response['photocounts']['photocount'] : false;
}
function photos_getExif ($photo_id, $secret = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getExif.html */
$this->request("flickr.photos.getExif", array("photo_id"=>$photo_id, "secret"=>$secret));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_getFavorites($photo_id, $page = NULL, $per_page = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getFavorites.html */
$this->request("flickr.photos.getFavorites", array("photo_id"=>$photo_id, "page"=>$page, "per_page"=>$per_page));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_getInfo($photo_id, $secret = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getInfo.html */
$this->request("flickr.photos.getInfo", array("photo_id"=>$photo_id, "secret"=>$secret));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_getNotInSet($min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getNotInSet.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.photos.getNotInSet", array("min_upload_date"=>$min_upload_date, "max_upload_date"=>$max_upload_date, "min_taken_date"=>$min_taken_date, "max_taken_date"=>$max_taken_date, "privacy_filter"=>$privacy_filter, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_getPerms($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.getPerms.html */
$this->request("flickr.photos.getPerms", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response['perms'] : false;
}
function photos_getRecent($extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getRecent.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.photos.getRecent", array("extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_getSizes($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.getSizes.html */
$this->request("flickr.photos.getSizes", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response['sizes']['size'] : false;
}
function photos_getUntagged($min_upload_date = NULL, $max_upload_date = NULL, $min_taken_date = NULL, $max_taken_date = NULL, $privacy_filter = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getUntagged.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.photos.getUntagged", array("min_upload_date"=>$min_upload_date, "max_upload_date"=>$max_upload_date, "min_taken_date"=>$min_taken_date, "max_taken_date"=>$max_taken_date, "privacy_filter"=>$privacy_filter, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_getWithGeoData($args = NULL) {
/** See the documentation included with the photos_search() function.
* I'm using the same style of arguments for this function. The only
* difference here is that this doesn't require any arguments. The
* flickr.photos.search method requires at least one search parameter.
*/
/** http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html */
if (is_null($args)) {
$args = array();
}
$this->request("flickr.photos.getWithGeoData", $args);
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_getWithoutGeoData($args = NULL) {
/** See the documentation included with the photos_search() function.
* I'm using the same style of arguments for this function. The only
* difference here is that this doesn't require any arguments. The
* flickr.photos.search method requires at least one search parameter.
*/
/** http://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html */
if (is_null($args)) {
$args = array();
}
$this->request("flickr.photos.getWithoutGeoData", $args);
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_recentlyUpdated($min_date = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.getUntagged.html */
if (is_array($extras)) {
$extras = implode(",", $extras);
}
$this->request("flickr.photos.recentlyUpdated", array("min_date"=>$min_date, "extras"=>$extras, "per_page"=>$per_page, "page"=>$page));
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_removeTag($tag_id)
{
/** http://www.flickr.com/services/api/flickr.photos.removeTag.html */
$this->request("flickr.photos.removeTag", array("tag_id"=>$tag_id), TRUE);
return $this->parsed_response ? true : false;
}
function photos_search($args)
{
/** This function strays from the method of arguments that I've
* used in the other functions for the fact that there are just
* so many arguments to this API method. What you'll need to do
* is pass an associative array to the function containing the
* arguments you want to pass to the API. For example:
* $photos = $f->photos_search(array("tags"=>"brown,cow", "tag_mode"=>"any"));
* This will return photos tagged with either "brown" or "cow"
* or both. See the API documentation (link below) for a full
* list of arguments.
*/
/** http://www.flickr.com/services/api/flickr.photos.search.html */
$this->request("flickr.photos.search", $args);
return $this->parsed_response ? $this->parsed_response['photos'] : false;
}
function photos_setContentType ($photo_id, $content_type) {
/** http://www.flickr.com/services/api/flickr.photos.setContentType.html */
return $this->call('flickr.photos.setContentType', array('photo_id' => $photo_id, 'content_type' => $content_type));
}
function photos_setDates($photo_id, $date_posted = NULL, $date_taken = NULL, $date_taken_granularity = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.setDates.html */
$this->request("flickr.photos.setDates", array("photo_id"=>$photo_id, "date_posted"=>$date_posted, "date_taken"=>$date_taken, "date_taken_granularity"=>$date_taken_granularity), TRUE);
return $this->parsed_response ? true : false;
}
function photos_setMeta($photo_id, $title, $description)
{
/** http://www.flickr.com/services/api/flickr.photos.setMeta.html */
$this->request("flickr.photos.setMeta", array("photo_id"=>$photo_id, "title"=>$title, "description"=>$description), TRUE);
return $this->parsed_response ? true : false;
}
function photos_setPerms($photo_id, $is_public, $is_friend, $is_family, $perm_comment, $perm_addmeta)
{
/** http://www.flickr.com/services/api/flickr.photos.setPerms.html */
$this->request("flickr.photos.setPerms", array("photo_id"=>$photo_id, "is_public"=>$is_public, "is_friend"=>$is_friend, "is_family"=>$is_family, "perm_comment"=>$perm_comment, "perm_addmeta"=>$perm_addmeta), TRUE);
return $this->parsed_response ? true : false;
}
function photos_setSafetyLevel ($photo_id, $safety_level, $hidden = null) {
/** http://www.flickr.com/services/api/flickr.photos.setSafetyLevel.html */
return $this->call('flickr.photos.setSafetyLevel', array('photo_id' => $photo_id, 'safety_level' => $safety_level, 'hidden' => $hidden));
}
function photos_setTags($photo_id, $tags)
{
/** http://www.flickr.com/services/api/flickr.photos.setTags.html */
$this->request("flickr.photos.setTags", array("photo_id"=>$photo_id, "tags"=>$tags), TRUE);
return $this->parsed_response ? true : false;
}
/** Photos - Comments Methods */
function photos_comments_addComment($photo_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photos.comments.addComment.html */
$this->request("flickr.photos.comments.addComment", array("photo_id" => $photo_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
function photos_comments_deleteComment($comment_id) {
/** http://www.flickr.com/services/api/flickr.photos.comments.deleteComment.html */
$this->request("flickr.photos.comments.deleteComment", array("comment_id" => $comment_id), TRUE);
return $this->parsed_response ? true : false;
}
function photos_comments_editComment($comment_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photos.comments.editComment.html */
$this->request("flickr.photos.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? true : false;
}
function photos_comments_getList($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.comments.getList.html */
$this->request("flickr.photos.comments.getList", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response['comments'] : false;
}
/** Photos - Geo Methods */
function photos_geo_getLocation($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.geo.getLocation.html */
$this->request("flickr.photos.geo.getLocation", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
function photos_geo_getPerms($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.geo.getPerms.html */
$this->request("flickr.photos.geo.getPerms", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response['perms'] : false;
}
function photos_geo_removeLocation($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.geo.removeLocation.html */
$this->request("flickr.photos.geo.removeLocation", array("photo_id"=>$photo_id), TRUE);
return $this->parsed_response ? true : false;
}
function photos_geo_setLocation($photo_id, $lat, $lon, $accuracy = NULL)
{
/** http://www.flickr.com/services/api/flickr.photos.geo.setLocation.html */
$this->request("flickr.photos.geo.setLocation", array("photo_id"=>$photo_id, "lat"=>$lat, "lon"=>$lon, "accuracy"=>$accuracy), TRUE);
return $this->parsed_response ? true : false;
}
function photos_geo_setPerms($photo_id, $is_public, $is_contact, $is_friend, $is_family)
{
/** http://www.flickr.com/services/api/flickr.photos.geo.setPerms.html */
$this->request("flickr.photos.geo.setPerms", array("photo_id"=>$photo_id, "is_public"=>$is_public, "is_contact"=>$is_contact, "is_friend"=>$is_friend, "is_family"=>$is_family), TRUE);
return $this->parsed_response ? true : false;
}
/** Photos - Licenses Methods */
function photos_licenses_getInfo()
{
/** http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.html */
$this->request("flickr.photos.licenses.getInfo");
return $this->parsed_response ? $this->parsed_response['licenses']['license'] : false;
}
function photos_licenses_setLicense($photo_id, $license_id)
{
/** http://www.flickr.com/services/api/flickr.photos.licenses.setLicense.html */
/** Requires Authentication */
$this->request("flickr.photos.licenses.setLicense", array("photo_id"=>$photo_id, "license_id"=>$license_id), TRUE);
return $this->parsed_response ? true : false;
}
/** Photos - Notes Methods */
function photos_notes_add($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text)
{
/** http://www.flickr.com/services/api/flickr.photos.notes.add.html */
$this->request("flickr.photos.notes.add", array("photo_id" => $photo_id, "note_x" => $note_x, "note_y" => $note_y, "note_w" => $note_w, "note_h" => $note_h, "note_text" => $note_text), TRUE);
return $this->parsed_response ? $this->parsed_response['note'] : false;
}
function photos_notes_delete($note_id)
{
/** http://www.flickr.com/services/api/flickr.photos.notes.delete.html */
$this->request("flickr.photos.notes.delete", array("note_id" => $note_id), TRUE);
return $this->parsed_response ? true : false;
}
function photos_notes_edit($note_id, $note_x, $note_y, $note_w, $note_h, $note_text)
{
/** http://www.flickr.com/services/api/flickr.photos.notes.edit.html */
$this->request("flickr.photos.notes.edit", array("note_id" => $note_id, "note_x" => $note_x, "note_y" => $note_y, "note_w" => $note_w, "note_h" => $note_h, "note_text" => $note_text), TRUE);
return $this->parsed_response ? true : false;
}
/** Photos - Transform Methods */
function photos_transform_rotate($photo_id, $degrees)
{
/** http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */
$this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE);
return $this->parsed_response ? true : false;
}
/** Photos - Upload Methods */
function photos_upload_checkTickets($tickets)
{
/** http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html */
if (is_array($tickets)) {
$tickets = implode(",", $tickets);
}
$this->request("flickr.photos.upload.checkTickets", array("tickets" => $tickets), TRUE);
return $this->parsed_response ? $this->parsed_response['uploader']['ticket'] : false;
}
/** Photosets Methods */
function photosets_addPhoto($photoset_id, $photo_id)
{
/** http://www.flickr.com/services/api/flickr.photosets.addPhoto.html */
$this->request("flickr.photosets.addPhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_create($title, $description, $primary_photo_id)
{
/** http://www.flickr.com/services/api/flickr.photosets.create.html */
$this->request("flickr.photosets.create", array("title" => $title, "primary_photo_id" => $primary_photo_id, "description" => $description), TRUE);
return $this->parsed_response ? $this->parsed_response['photoset'] : false;
}
function photosets_delete($photoset_id)
{
/** http://www.flickr.com/services/api/flickr.photosets.delete.html */
$this->request("flickr.photosets.delete", array("photoset_id" => $photoset_id), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_editMeta($photoset_id, $title, $description = NULL)
{
/** http://www.flickr.com/services/api/flickr.photosets.editMeta.html */
$this->request("flickr.photosets.editMeta", array("photoset_id" => $photoset_id, "title" => $title, "description" => $description), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_editPhotos($photoset_id, $primary_photo_id, $photo_ids)
{
/** http://www.flickr.com/services/api/flickr.photosets.editPhotos.html */
$this->request("flickr.photosets.editPhotos", array("photoset_id" => $photoset_id, "primary_photo_id" => $primary_photo_id, "photo_ids" => $photo_ids), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_getContext($photo_id, $photoset_id)
{
/** http://www.flickr.com/services/api/flickr.photosets.getContext.html */
$this->request("flickr.photosets.getContext", array("photo_id" => $photo_id, "photoset_id" => $photoset_id));
return $this->parsed_response ? $this->parsed_response : false;
}
function photosets_getInfo($photoset_id)
{
/** http://www.flickr.com/services/api/flickr.photosets.getInfo.html */
$this->request("flickr.photosets.getInfo", array("photoset_id" => $photoset_id));
return $this->parsed_response ? $this->parsed_response['photoset'] : false;
}
function photosets_getList($user_id = NULL)
{
/** http://www.flickr.com/services/api/flickr.photosets.getList.html */
$this->request("flickr.photosets.getList", array("user_id" => $user_id));
return $this->parsed_response ? $this->parsed_response['photosets'] : false;
}
function photosets_getPhotos($photoset_id, $extras = NULL, $privacy_filter = NULL, $per_page = NULL, $page = NULL)
{
/** http://www.flickr.com/services/api/flickr.photosets.getPhotos.html */
$this->request("flickr.photosets.getPhotos", array("photoset_id" => $photoset_id, "extras" => $extras, "privacy_filter" => $privacy_filter, "per_page" => $per_page, "page" => $page));
return $this->parsed_response ? $this->parsed_response['photoset'] : false;
}
function photosets_orderSets($photoset_ids)
{
/** http://www.flickr.com/services/api/flickr.photosets.orderSets.html */
if (is_array($photoset_ids)) {
$photoset_ids = implode(",", $photoset_ids);
}
$this->request("flickr.photosets.orderSets", array("photoset_ids" => $photoset_ids), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_removePhoto($photoset_id, $photo_id)
{
/** http://www.flickr.com/services/api/flickr.photosets.removePhoto.html */
$this->request("flickr.photosets.removePhoto", array("photoset_id" => $photoset_id, "photo_id" => $photo_id), TRUE);
return $this->parsed_response ? true : false;
}
/** Photosets Comments Methods */
function photosets_comments_addComment($photoset_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photosets.comments.addComment.html */
$this->request("flickr.photosets.comments.addComment", array("photoset_id" => $photoset_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
function photosets_comments_deleteComment($comment_id) {
/** http://www.flickr.com/services/api/flickr.photosets.comments.deleteComment.html */
$this->request("flickr.photosets.comments.deleteComment", array("comment_id" => $comment_id), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_comments_editComment($comment_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photosets.comments.editComment.html */
$this->request("flickr.photosets.comments.editComment", array("comment_id" => $comment_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? true : false;
}
function photosets_comments_getList($photoset_id)
{
/** http://www.flickr.com/services/api/flickr.photosets.comments.getList.html */
$this->request("flickr.photosets.comments.getList", array("photoset_id"=>$photoset_id));
return $this->parsed_response ? $this->parsed_response['comments'] : false;
}
/** Places Methods */
function places_resolvePlaceId ($place_id) {
/** http://www.flickr.com/services/api/flickr.places.resolvePlaceId.html */
$rsp = $this->call('flickr.places.resolvePlaceId', array('place_id' => $place_id));
return $rsp ? $rsp['location'] : $rsp;
}
function places_resolvePlaceURL ($url) {
/** http://www.flickr.com/services/api/flickr.places.resolvePlaceURL.html */
$rsp = $this->call('flickr.places.resolvePlaceURL', array('url' => $url));
return $rsp ? $rsp['location'] : $rsp;
}
/** Prefs Methods */
function prefs_getContentType () {
/** http://www.flickr.com/services/api/flickr.prefs.getContentType.html */
$rsp = $this->call('flickr.prefs.getContentType', array());
return $rsp ? $rsp['person'] : $rsp;
}
function prefs_getHidden () {
/** http://www.flickr.com/services/api/flickr.prefs.getHidden.html */
$rsp = $this->call('flickr.prefs.getHidden', array());
return $rsp ? $rsp['person'] : $rsp;
}
function prefs_getPrivacy () {
/** http://www.flickr.com/services/api/flickr.prefs.getPrivacy.html */
$rsp = $this->call('flickr.prefs.getPrivacy', array());
return $rsp ? $rsp['person'] : $rsp;
}
function prefs_getSafetyLevel () {
/** http://www.flickr.com/services/api/flickr.prefs.getSafetyLevel.html */
$rsp = $this->call('flickr.prefs.getSafetyLevel', array());
return $rsp ? $rsp['person'] : $rsp;
}
/** Reflection Methods */
function reflection_getMethodInfo($method_name)
{
/** http://www.flickr.com/services/api/flickr.reflection.getMethodInfo.html */
$this->request("flickr.reflection.getMethodInfo", array("method_name" => $method_name));
return $this->parsed_response ? $this->parsed_response : false;
}
function reflection_getMethods()
{
/** http://www.flickr.com/services/api/flickr.reflection.getMethods.html */
$this->request("flickr.reflection.getMethods");
return $this->parsed_response ? $this->parsed_response['methods']['method'] : false;
}