File: Flickr.cs

package info (click to toggle)
libflickrnet 25277-6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 628 kB
  • ctags: 1,355
  • sloc: cs: 7,136; makefile: 24; sh: 13; ansic: 6
file content (5266 lines) | stat: -rw-r--r-- 197,091 bytes parent folder | download
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
using System;
using System.Net;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Serialization;
using System.Text;
using System.Collections;
using System.Collections.Specialized;

namespace FlickrNet
{
	/// <summary>
	/// The main Flickr class.
	/// </summary>
	/// <remarks>
	/// Create an instance of this class and then call its methods to perform methods on Flickr.
	/// </remarks>
	/// <example>
	/// <code>FlickrNet.Flickr flickr = new FlickrNet.Flickr();
	/// User user = flickr.PeopleFindByEmail("cal@iamcal.com");
	/// Console.WriteLine("User Id is " + u.UserId);</code>
	/// </example>
	//[System.Net.WebPermission(System.Security.Permissions.SecurityAction.Demand, ConnectPattern="http://www.flickr.com/.*")]
	public class Flickr
	{

		#region [ Upload Event and Delegate ]
		/// <summary>
		/// 
		/// </summary>
		public delegate void UploadProgressHandler(object sender, UploadProgressEventArgs e);

		/// <summary>
		/// UploadProgressHandler is fired during a synchronous upload process to signify that 
		/// a segment of uploading has been completed. This is approximately 50 bytes. The total
		/// uploaded is recorded in the <see cref="UploadProgressEventArgs"/> class.
		/// </summary>
		public event UploadProgressHandler OnUploadProgress;
		#endregion

		#region [ Private Variables ]
#if !WindowsCE
		private static bool _isServiceSet = false;
#endif
		private static SupportedService _defaultService = SupportedService.Flickr;

		private SupportedService _service = SupportedService.Flickr;

		private string BaseUrl
		{
			get { return _baseUrl[(int)_service]; }
		}

		private string[] _baseUrl = new string[] { 
															"http://api.flickr.com/services/rest/", 
															"http://beta.zooomr.com/bluenote/api/rest",
															"http://www.23hq.com/services/rest/"};

		private string UploadUrl
		{
			get { return _uploadUrl[(int)_service]; }
		}
		private static string[] _uploadUrl = new string[] {
															  "http://api.flickr.com/services/upload/",
															  "http://beta.zooomr.com/bluenote/api/upload",
															  "http://www.23hq.com/services/upload/"};

		private string ReplaceUrl
		{
			get { return _replaceUrl[(int)_service]; }
		}
		private static string[] _replaceUrl = new string[] {
															   "http://api.flickr.com/services/replace/",
															   "http://beta.zooomr.com/bluenote/api/replace",
															   "http://www.23hq.com/services/replace/"};

		private string AuthUrl
		{
			get { return _authUrl[(int)_service]; }
		}
		private static string[] _authUrl = new string[] {
															   "http://www.flickr.com/services/auth/",
															   "http://beta.zooomr.com/auth/",
															   "http://www.23hq.com/services/auth/"};

		private string _apiKey;
		private string _apiToken;
		private string _sharedSecret;
		private int _timeout = 30000;
		private const string UserAgent = "Mozilla/4.0 FlickrNet API (compatible; MSIE 6.0; Windows NT 5.1)";
		private string _lastRequest;
		private string _lastResponse;

		private WebProxy _proxy;// = WebProxy.GetDefaultProxy();

		// Static serializers
		private static XmlSerializer _responseSerializer = new XmlSerializer(typeof(FlickrNet.Response));
		private static XmlSerializer _uploaderSerializer = new XmlSerializer(typeof(FlickrNet.Uploader));

		#endregion

		#region [ Public Properties ]
		/// <summary>
		/// Get or set the API Key to be used by all calls. API key is mandatory for all 
		/// calls to Flickr.
		/// </summary>
		public string ApiKey 
		{ 
			get { return _apiKey; } 
			set { _apiKey = (value==null||value.Length==0?null:value); }
		}

		/// <summary>
		/// API shared secret is required for all calls that require signing, which includes
		/// all methods that require authentication, as well as the actual flickr.auth.* calls.
		/// </summary>
		public string ApiSecret
		{
			get { return _sharedSecret; }
			set { _sharedSecret = (value==null||value.Length==0?null:value); }
		}

		/// <summary>
		/// The API token is required for all calls that require authentication.
		/// A <see cref="FlickrException"/> will be raised by Flickr if the API token is
		/// not set when required.
		/// </summary>
		/// <remarks>
		/// It should be noted that some methods will work without the API token, but
		/// will return different results if used with them (such as group pool requests, 
		/// and results which include private pictures the authenticated user is allowed to see
		/// (their own, or others).
		/// </remarks>
		[Obsolete("Renamed to AuthToken to be more consistent with the Flickr API")]
		public string ApiToken 
		{
			get { return _apiToken; }
			set { _apiToken = (value==null||value.Length==0?null:value); }
		}

		/// <summary>
		/// The authentication token is required for all calls that require authentication.
		/// A <see cref="FlickrException"/> will be raised by Flickr if the authentication token is
		/// not set when required.
		/// </summary>
		/// <remarks>
		/// It should be noted that some methods will work without the authentication token, but
		/// will return different results if used with them (such as group pool requests, 
		/// and results which include private pictures the authenticated user is allowed to see
		/// (their own, or others).
		/// </remarks>
		public string AuthToken 
		{
			get { return _apiToken; }
			set { _apiToken = (value==null||value.Length==0?null:value); }
		}

		/// <summary>
		/// Gets or sets whether the cache should be disabled. Use only in extreme cases where you are sure you
		/// don't want any caching.
		/// </summary>
		public static bool CacheDisabled
		{
			get { return Cache.CacheDisabled; }
			set { Cache.CacheDisabled = value; }
		}

		/// <summary>
		/// All GET calls to Flickr are cached by the Flickr.Net API. Set the <see cref="CacheTimeout"/>
		/// to determine how long these calls should be cached (make this as long as possible!)
		/// </summary>
		public static TimeSpan CacheTimeout
		{
			get { return Cache.CacheTimeout; }
			set { Cache.CacheTimeout = value; }
		}

		/// <summary>
		/// Sets or gets the location to store the Cache files.
		/// </summary>
		public static string CacheLocation
		{
			get { return Cache.CacheLocation; }
			set { Cache.CacheLocation = value; }
		}

		/// <summary>
		/// Gets the current size of the Cache.
		/// </summary>
		public static long CacheSize
		{
			get { return Cache.CacheSize; }
		}

		/// <summary>
		/// <see cref="CacheSizeLimit"/> is the cache file size in bytes for downloaded
		/// pictures. The default is 50MB (or 50 * 1024 * 1025 in bytes).
		/// </summary>
		public static long CacheSizeLimit
		{
			get { return Cache.CacheSizeLimit; }
			set { Cache.CacheSizeLimit = value; }
		}

		/// <summary>
		/// The default service to use for new Flickr instances
		/// </summary>
		public static SupportedService DefaultService
		{
			get 
			{
#if !WindowsCE
				if( !_isServiceSet && FlickrConfigurationManager.Settings != null )
				{
					_defaultService = FlickrConfigurationManager.Settings.Service;
					_isServiceSet = true;
				}
#endif
                return _defaultService;
			}
			set
			{
				_defaultService = value;
#if !WindowsCE
				_isServiceSet = true;
#endif
			}
		}

		/// <summary>
		/// The current service that the Flickr API is using.
		/// </summary>
		public SupportedService CurrentService
		{
			get 
			{ 
				return _service; 
			}
			set 
			{
				_service = value; 
#if !WindowsCE
				if( _service == SupportedService.Zooomr ) ServicePointManager.Expect100Continue = false;
#endif
			}
		}

		/// <summary>
		/// Internal timeout for all web requests in milliseconds. Defaults to 30 seconds.
		/// </summary>
		public int HttpTimeout
		{
			get { return _timeout; } 
			set { _timeout = value; }
		}

		/// <summary>
		/// Checks to see if a shared secret and an api token are stored in the object.
		/// Does not check if these values are valid values.
		/// </summary>
		public bool IsAuthenticated
		{
			get { return (_sharedSecret != null && _apiToken != null); }
		}

		/// <summary>
		/// Returns the raw XML returned from the last response.
		/// Only set it the response was not returned from cache.
		/// </summary>
		public string LastResponse
		{
			get { return _lastResponse; }
		}

		/// <summary>
		/// Returns the last URL requested. Includes API signing.
		/// </summary>
		public string LastRequest
		{
			get { return _lastRequest; }
		}

		/// <summary>
		/// You can set the <see cref="WebProxy"/> or alter its properties.
		/// It defaults to your internet explorer proxy settings.
		/// </summary>
		public WebProxy Proxy { get { return _proxy; } set { _proxy = value; } }
		#endregion

		#region [ Cache Methods ]
		/// <summary>
		/// Clears the cache completely.
		/// </summary>
		public static void FlushCache()
		{
			Cache.FlushCache();
		}

		/// <summary>
		/// Clears the cache for a particular URL.
		/// </summary>
		/// <param name="url">The URL to remove from the cache.</param>
		/// <remarks>
		/// The URL can either be an image URL for a downloaded picture, or
		/// a request URL (see <see cref="LastRequest"/> for getting the last URL).
		/// </remarks>
		public static void FlushCache(string url)
		{
			Cache.FlushCache(url);
		}

		/// <summary>
		/// Provides static access to the list of cached photos.
		/// </summary>
		/// <returns>An array of <see cref="PictureCacheItem"/> objects.</returns>
		public static PictureCacheItem[] GetCachePictures()
		{
			return (PictureCacheItem[]) Cache.Downloads.ToArray(typeof(PictureCacheItem));
		}
		#endregion

		#region [ Constructors ]

		/// <summary>
		/// Constructor loads configuration settings from app.config or web.config file if they exist.
		/// </summary>
		public Flickr()
        {
#if !WindowsCE
            FlickrConfigurationSettings settings = FlickrConfigurationManager.Settings;
			if( settings == null ) return;

			if( settings.CacheSize != 0 ) CacheSizeLimit = settings.CacheSize;
			if( settings.CacheTimeout != TimeSpan.MinValue ) CacheTimeout = settings.CacheTimeout;
			ApiKey = settings.ApiKey;
			AuthToken = settings.ApiToken;
			ApiSecret = settings.SharedSecret;

            if (settings.IsProxyDefined)
			{
				Proxy = new WebProxy();
				Proxy.Address = new Uri("http://" + settings.ProxyIPAddress + ":" + settings.ProxyPort);
				if( settings.ProxyUsername != null && settings.ProxyUsername.Length > 0 )
				{
					NetworkCredential creds = new NetworkCredential();
					creds.UserName = settings.ProxyUsername;
					creds.Password = settings.ProxyPassword;
					creds.Domain = settings.ProxyDomain;
					Proxy.Credentials = creds;
				}
			}
			else
			{
				// try and get default IE settings
				try
				{
					Proxy = WebProxy.GetDefaultProxy();
				}
				catch(System.Security.SecurityException)
				{
					// Capture SecurityException for when running in a Medium Trust environment.
				}
			}

#endif

            CurrentService = DefaultService;
		}

		/// <summary>
		/// Create a new instance of the <see cref="Flickr"/> class with no authentication.
		/// </summary>
		/// <param name="apiKey">Your Flickr API Key.</param>
		public Flickr(string apiKey) : this(apiKey, "", "")
		{
		}

		/// <summary>
		/// Creates a new instance of the <see cref="Flickr"/> class with an API key and a Shared Secret.
		/// This is only useful really useful for calling the Auth functions as all other
		/// authenticationed methods also require the API Token.
		/// </summary>
		/// <param name="apiKey">Your Flickr API Key.</param>
		/// <param name="sharedSecret">Your Flickr Shared Secret.</param>
		public Flickr(string apiKey, string sharedSecret) : this(apiKey, sharedSecret, "")
		{
		}

		/// <summary>
		/// Create a new instance of the <see cref="Flickr"/> class with the email address and password given
		/// </summary>
		/// <param name="apiKey">Your Flickr API Key</param>
		/// <param name="sharedSecret">Your FLickr Shared Secret.</param>
		/// <param name="token">The token for the user who has been authenticated.</param>
		public Flickr(string apiKey, string sharedSecret, string token) : this()
		{
			_apiKey = apiKey;
			_sharedSecret = sharedSecret;
			_apiToken = token;
		}
		#endregion

		#region [ Private Methods ]
		/// <summary>
		/// A private method which performs the actual HTTP web request if
		/// the details are not found within the cache.
		/// </summary>
		/// <param name="url">The URL to download.</param>
		/// <param name="variables">The query string parameters to be added to the end of the URL.</param>
		/// <returns>A <see cref="FlickrNet.Response"/> object.</returns>
		/// <remarks>If the final length of the URL would be greater than 2000 characters 
		/// then they are sent as part of the body instead.</remarks>
		private string DoGetResponse(string url, string variables)
		{
			HttpWebRequest req = null;
			HttpWebResponse res = null;

			if( variables.Length < 2000 )
			{
				url += "?" + variables;
				variables = "";
			}

			// Initialise the web request
			req = (HttpWebRequest)HttpWebRequest.Create(url);
			req.Method = CurrentService==SupportedService.Zooomr?"GET":"POST";

            if (req.Method == "POST") req.ContentLength = variables.Length;

            req.UserAgent = UserAgent;
			if( Proxy != null ) req.Proxy = Proxy;
			req.Timeout = HttpTimeout;
			req.KeepAlive = false;
            if (variables.Length > 0)
            {
                req.ContentType = "application/x-www-form-urlencoded";
                StreamWriter sw = new StreamWriter(req.GetRequestStream());
                sw.Write(variables);
                sw.Close();
            }
            else
            {
                // This is needed in the Compact Framework
                // See for more details: http://msdn2.microsoft.com/en-us/library/1afx2b0f.aspx
                req.GetRequestStream().Close();
            }

			try
			{
				// Get response from the internet
				res = (HttpWebResponse)req.GetResponse();
			}
			catch(WebException ex)
			{
				if( ex.Status == WebExceptionStatus.ProtocolError )
				{
					HttpWebResponse res2 = (HttpWebResponse)ex.Response;
					if( res2 != null )
					{
						throw new FlickrWebException(String.Format("HTTP Error {0}, {1}", (int)res2.StatusCode, res2.StatusDescription), ex);
					}
				}
				throw new FlickrWebException(ex.Message, ex);
			}

			string responseString = string.Empty;

			using (StreamReader sr = new StreamReader(res.GetResponseStream()))
			{
				responseString = sr.ReadToEnd();
			}

			return responseString;
		}

		/// <summary>
		/// Download a picture (or anything else actually).
		/// </summary>
		/// <param name="url"></param>
		/// <returns></returns>
		private Stream DoDownloadPicture(string url)
		{
			HttpWebRequest req = null;
			HttpWebResponse res = null;

			try
			{
				req = (HttpWebRequest)HttpWebRequest.Create(url);
				req.UserAgent = UserAgent;
				if( Proxy != null ) req.Proxy = Proxy;
				req.Timeout = HttpTimeout;
				req.KeepAlive = false;
				res = (HttpWebResponse)req.GetResponse();
			}
			catch(WebException ex)
			{
				if( ex.Status == WebExceptionStatus.ProtocolError )
				{
					HttpWebResponse res2 = (HttpWebResponse)ex.Response;
					if( res2 != null )
					{
						throw new FlickrWebException(String.Format("HTTP Error while downloading photo: {0}, {1}", (int)res2.StatusCode, res2.StatusDescription), ex);
					}
				}
				else if( ex.Status == WebExceptionStatus.Timeout )
				{
					throw new FlickrWebException("The request timed-out", ex);
				}
				throw new FlickrWebException("Picture download failed (" + ex.Message + ")", ex);
			}

			return res.GetResponseStream();
		}

		private void CheckApiKey()
		{
			if( ApiKey == null || ApiKey.Length == 0 )
				throw new ApiKeyRequiredException();
		}
		private void CheckRequiresAuthentication()
		{
			CheckApiKey();

			if( ApiSecret == null || ApiSecret.Length == 0 )
				throw new SignatureRequiredException();
			if( AuthToken == null || AuthToken.Length == 0 )
				throw new AuthenticationRequiredException();

		}
		
		#endregion

		#region [ GetResponse methods ]
		private Response GetResponseNoCache(Hashtable parameters)
		{
			return GetResponse(parameters, TimeSpan.MinValue);
		}

		private Response GetResponseAlwaysCache(Hashtable parameters)
		{
			return GetResponse(parameters, TimeSpan.MaxValue);
		}

		private Response GetResponseCache(Hashtable parameters)
		{
			return GetResponse(parameters, Cache.CacheTimeout);
		}

		private Response GetResponse(Hashtable parameters, TimeSpan cacheTimeout)
		{
			CheckApiKey();

			// Calulate URL 
			string url = BaseUrl;

            StringBuilder UrlStringBuilder = new StringBuilder("", 2 * 1024);
            StringBuilder HashStringBuilder = new StringBuilder(_sharedSecret, 2 * 1024);

			parameters["api_key"] = _apiKey;

			if( _apiToken != null && _apiToken.Length > 0 )
			{
				parameters["auth_token"] = _apiToken;
			}

			string[] keys = new string[parameters.Keys.Count];
			parameters.Keys.CopyTo(keys, 0);
			Array.Sort(keys);

			foreach(string key in keys)
			{
				if( UrlStringBuilder.Length > 0 ) UrlStringBuilder.Append("&");
                UrlStringBuilder.Append(key);
                UrlStringBuilder.Append("=");
                UrlStringBuilder.Append(Utils.UrlEncode(Convert.ToString(parameters[key])));
                HashStringBuilder.Append(key);
                HashStringBuilder.Append(parameters[key]);
			}

            if (_sharedSecret != null && _sharedSecret.Length > 0) 
            {
                if (UrlStringBuilder.Length > BaseUrl.Length + 1)
                {
                    UrlStringBuilder.Append("&");
                }
                UrlStringBuilder.Append("api_sig=");
                UrlStringBuilder.Append(Md5Hash(HashStringBuilder.ToString()));
            }

			string variables = UrlStringBuilder.ToString();
			_lastRequest = url;
			_lastResponse = string.Empty;

			if( CacheDisabled )
			{
				string responseXml = DoGetResponse(url, variables);
				_lastResponse = responseXml;
				return Utils.Deserialize(responseXml);
			}
			else
			{
				ResponseCacheItem cached = (ResponseCacheItem) Cache.Responses.Get(url + "?" + variables, cacheTimeout, true);
				if (cached != null)
				{
					System.Diagnostics.Debug.WriteLine("Cache hit");
					_lastResponse = cached.Response;
					return Utils.Deserialize(cached.Response);
				}
				else
				{
					System.Diagnostics.Debug.WriteLine("Cache miss");
					string responseXml = DoGetResponse(url, variables);
					_lastResponse = responseXml;

					ResponseCacheItem resCache = new ResponseCacheItem();
					resCache.Response = responseXml;
					resCache.Url = url;
					resCache.CreationTime = DateTime.UtcNow;

					FlickrNet.Response response = Utils.Deserialize(responseXml);

					if( response.Status == ResponseStatus.OK )
					{
						Cache.Responses.Shrink(Math.Max(0, Cache.CacheSizeLimit - responseXml.Length));
						Cache.Responses[url] = resCache;
					}

					return response;
				}
			}
		}

		#endregion

		#region [ DownloadPicture ]
		/// <summary>
		/// Downloads the picture from a internet and transfers it to a stream object.
		/// </summary>
		/// <param name="url">The url of the image to download.</param>
		/// <returns>A <see cref="Stream"/> object containing the downloaded picture.</returns>
		/// <remarks>
		/// The method checks the download cache first to see if the picture has already 
		/// been downloaded and if so returns the cached image. Otherwise it goes to the internet for the actual 
		/// image.
		/// </remarks>
		public System.IO.Stream DownloadPicture(string url)
		{
			if( CacheDisabled )
			{
				return DoDownloadPicture(url);
			}

			const int BUFFER_SIZE = 1024 * 10;

			PictureCacheItem cacheItem = (PictureCacheItem) Cache.Downloads[url];
			if (cacheItem != null)
			{
				return  new FileStream(cacheItem.filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
			}

			PictureCacheItem picCache = new PictureCacheItem();
			picCache.filename = Path.Combine(Cache.CacheLocation,Guid.NewGuid().ToString());
			Stream read = DoDownloadPicture(url);
			Stream write = new FileStream(picCache.filename, FileMode.Create, FileAccess.Write, FileShare.None);

			byte[] buffer = new byte[BUFFER_SIZE];
			int bytes = 0;
			long fileSize = 0;

			while( (bytes = read.Read(buffer, 0, BUFFER_SIZE)) > 0 )
			{
				fileSize += bytes;
				write.Write(buffer, 0, bytes);
			}

			read.Close();
			write.Close();

			picCache.url = url;
			picCache.creationTime = DateTime.UtcNow;
			picCache.fileSize = fileSize;

			Cache.Downloads.Shrink(Math.Max(0, Cache.CacheSizeLimit - fileSize));
			Cache.Downloads[url] = picCache;

			return new FileStream(picCache.filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
		}
		#endregion

		#region [ Auth ]
		/// <summary>
		/// Retrieve a temporary FROB from the Flickr service, to be used in redirecting the
		/// user to the Flickr web site for authentication. Only required for desktop authentication.
		/// </summary>
		/// <remarks>
		/// Pass the FROB to the <see cref="AuthCalcUrl"/> method to calculate the url.
		/// </remarks>
		/// <example>
		/// <code>
		/// string frob = flickr.AuthGetFrob();
		/// string url = flickr.AuthCalcUrl(frob, AuthLevel.Read);
		/// 
		/// // redirect the user to the url above and then wait till they have authenticated and return to the app.
		/// 
		/// Auth auth = flickr.AuthGetToken(frob);
		/// 
		/// // then store the auth.Token for later use.
		/// string token = auth.Token;
		/// </code>
		/// </example>
		/// <returns>The FROB.</returns>
		public string AuthGetFrob()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.auth.getFrob");
			
			FlickrNet.Response response = GetResponseNoCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				return response.AllElements[0].InnerText;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Calculates the URL to redirect the user to Flickr web site for
		/// authentication. Used by desktop application. 
		/// See <see cref="AuthGetFrob"/> for example code.
		/// </summary>
		/// <param name="frob">The FROB to be used for authentication.</param>
		/// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
		/// <returns>The url to redirect the user to.</returns>
		public string AuthCalcUrl(string frob, AuthLevel authLevel)
		{
			if( _sharedSecret == null ) throw new SignatureRequiredException();

			string hash = _sharedSecret + "api_key" + _apiKey + "frob" + frob + "perms" + authLevel.ToString().ToLower();
			hash = Md5Hash(hash);
			string url = AuthUrl + "?api_key=" + _apiKey + "&perms=" + authLevel.ToString().ToLower() + "&frob=" + frob;
			url += "&api_sig=" + hash;

			return url;
		}

		/// <summary>
		/// Calculates the URL to redirect the user to Flickr web site for
		/// auehtntication. Used by Web applications. 
		/// See <see cref="AuthGetFrob"/> for example code.
		/// </summary>
		/// <remarks>
		/// The Flickr web site provides 'tiny urls' that can be used in place
		/// of this URL when you specify your return url in the API key page.
		/// It is recommended that you use these instead as they do not include
		/// your API or shared secret.
		/// </remarks>
		/// <param name="authLevel">The <see cref="AuthLevel"/> stating the maximum authentication level your application requires.</param>
		/// <returns>The url to redirect the user to.</returns>
		public string AuthCalcWebUrl(AuthLevel authLevel)
		{
			if( _sharedSecret == null ) throw new SignatureRequiredException();

			string hash = _sharedSecret + "api_key" + _apiKey + "perms" + authLevel.ToString().ToLower();
			hash = Md5Hash(hash);
			string url = AuthUrl + "?api_key=" + _apiKey + "&perms=" + authLevel.ToString().ToLower();
			url += "&api_sig=" + hash;

			return url;
		}

		/// <summary>
		/// After the user has authenticated your application on the flickr web site call this 
		/// method with the FROB (either stored from <see cref="AuthGetFrob"/> or returned in the URL
		/// from the Flickr web site) to get the users token.
		/// </summary>
		/// <param name="frob">The string containing the FROB.</param>
		/// <returns>A <see cref="Auth"/> object containing user and token details.</returns>
		public Auth AuthGetToken(string frob)
		{
			if( _sharedSecret == null ) throw new SignatureRequiredException();

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.auth.getToken");
			parameters.Add("frob", frob);

			FlickrNet.Response response = GetResponseNoCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				Auth auth = new Auth(response.AllElements[0]);
				return auth;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the full token details for a given mini token, entered by the user following a 
		/// web based authentication.
		/// </summary>
		/// <param name="miniToken">The mini token.</param>
		/// <returns>An instance <see cref="Auth"/> class, detailing the user and their full token.</returns>
		public Auth AuthGetFullToken(string miniToken)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.auth.getFullToken");
			parameters.Add("mini_token", miniToken.Replace("-", ""));
			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				Auth auth = new Auth(response.AllElements[0]);
				return auth;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Checks a authentication token with the flickr service to make
		/// sure it is still valid.
		/// </summary>
		/// <param name="token">The authentication token to check.</param>
		/// <returns>The <see cref="Auth"/> object detailing the user for the token.</returns>
		public Auth AuthCheckToken(string token)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.auth.checkToken");
			parameters.Add("auth_token", token);

			FlickrNet.Response response = GetResponseNoCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				Auth auth = new Auth(response.AllElements[0]);
				return auth;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}
		#endregion
				
		#region [ Activity ]
		/// <summary>
		/// Returns a list of recent activity on photos belonging to the calling user.
		/// </summary>
		/// <remarks>
		/// <b>Do not poll this method more than once an hour.</b>
		/// </remarks>
		/// <returns>An array of <see cref="ActivityItem"/> instances.</returns>
		public ActivityItem[] ActivityUserPhotos()
		{
			return ActivityUserPhotos(null);
		}

		/// <summary>
		/// Returns a list of recent activity on photos belonging to the calling user.
		/// </summary>
		/// <remarks>
		/// <b>Do not poll this method more than once an hour.</b>
		/// </remarks>
		/// <param name="timePeriod">The number of days or hours you want to get activity for.</param>
		/// <param name="timeType">'d' for days, 'h' for hours.</param>
		/// <returns>An array of <see cref="ActivityItem"/> instances.</returns>
		public ActivityItem[] ActivityUserPhotos(int timePeriod, string timeType)
		{
			if( timePeriod == 0 ) 
				throw new ArgumentOutOfRangeException("timePeriod", "Time Period should be greater than 0");

			if( timeType == null ) 
				throw new ArgumentNullException("timeType");

			if( timeType != "d" && timeType != "h" )
				throw new ArgumentOutOfRangeException("timeType", "Time type must be 'd' or 'h'");

			return ActivityUserPhotos(timePeriod + timeType);
		}

		private ActivityItem[] ActivityUserPhotos(string timeframe)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.activity.userPhotos");
			if( timeframe != null && timeframe.Length > 0 ) parameters.Add("timeframe", timeframe);
			
			FlickrNet.Response response = GetResponseCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				XmlNodeList list = response.AllElements[0].SelectNodes("item");
				ActivityItem[] items = new ActivityItem[list.Count];
				for(int i = 0; i < items.Length; i++)
				{
					items[i] = new ActivityItem(list[i]);
				}
				return items;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a list of recent activity on photos commented on by the calling user.
		/// </summary>
		/// <remarks>
		/// <b>Do not poll this method more than once an hour.</b>
		/// </remarks>
		/// <returns></returns>
		public ActivityItem[] ActivityUserComments(int page, int perPage)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.activity.userComments");
			if( page > 0 ) parameters.Add("page", page);
			if( perPage > 0 ) parameters.Add("per_page", perPage);

			FlickrNet.Response response = GetResponseCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				XmlNodeList list = response.AllElements[0].SelectNodes("item");
				ActivityItem[] items = new ActivityItem[list.Count];
				for(int i = 0; i < items.Length; i++)
				{
					items[i] = new ActivityItem(list[i]);
				}
				return items;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ UploadPicture ]
		/// <summary>
		/// Uploads a file to Flickr.
		/// </summary>
		/// <param name="filename">The filename of the file to open.</param>
		/// <returns>The id of the photo on a successful upload.</returns>
		/// <exception cref="FlickrException">Thrown when Flickr returns an error. see http://www.flickr.com/services/api/upload.api.html for more details.</exception>
		/// <remarks>Other exceptions may be thrown, see <see cref="FileStream"/> constructors for more details.</remarks>
		public string UploadPicture(string filename)
		{
			return UploadPicture(filename, null, null, null, true, false, false);
		}

		/// <summary>
		/// Uploads a file to Flickr.
		/// </summary>
		/// <param name="filename">The filename of the file to open.</param>
		/// <param name="title">The title of the photograph.</param>
		/// <returns>The id of the photo on a successful upload.</returns>
		/// <exception cref="FlickrException">Thrown when Flickr returns an error. see http://www.flickr.com/services/api/upload.api.html for more details.</exception>
		/// <remarks>Other exceptions may be thrown, see <see cref="FileStream"/> constructors for more details.</remarks>
		public string UploadPicture(string filename, string title)
		{
			return UploadPicture(filename, title, null, null, true, false, false);
		}

		/// <summary>
		/// Uploads a file to Flickr.
		/// </summary>
		/// <param name="filename">The filename of the file to open.</param>
		/// <param name="title">The title of the photograph.</param>
		/// <param name="description">The description of the photograph.</param>
		/// <returns>The id of the photo on a successful upload.</returns>
		/// <exception cref="FlickrException">Thrown when Flickr returns an error. see http://www.flickr.com/services/api/upload.api.html for more details.</exception>
		/// <remarks>Other exceptions may be thrown, see <see cref="FileStream"/> constructors for more details.</remarks>
		public string UploadPicture(string filename, string title, string description)
		{
			return UploadPicture(filename, title, description, null, true, false, false);
		}

		/// <summary>
		/// Uploads a file to Flickr.
		/// </summary>
		/// <param name="filename">The filename of the file to open.</param>
		/// <param name="title">The title of the photograph.</param>
		/// <param name="description">The description of the photograph.</param>
		/// <param name="tags">A comma seperated list of the tags to assign to the photograph.</param>
		/// <returns>The id of the photo on a successful upload.</returns>
		/// <exception cref="FlickrException">Thrown when Flickr returns an error. see http://www.flickr.com/services/api/upload.api.html for more details.</exception>
		/// <remarks>Other exceptions may be thrown, see <see cref="FileStream"/> constructors for more details.</remarks>
		public string UploadPicture(string filename, string title, string description, string tags)
		{
			Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
			return UploadPicture(stream, title, description, tags, -1, -1, -1, ContentType.None, SafetyLevel.None, HiddenFromSearch.None);
		}

		/// <summary>
		/// Uploads a file to Flickr.
		/// </summary>
		/// <param name="filename">The filename of the file to open.</param>
		/// <param name="title">The title of the photograph.</param>
		/// <param name="description">The description of the photograph.</param>
		/// <param name="tags">A comma seperated list of the tags to assign to the photograph.</param>
		/// <param name="isPublic">True if the photograph should be public and false if it should be private.</param>
		/// <param name="isFriend">True if the photograph should be marked as viewable by friends contacts.</param>
		/// <param name="isFamily">True if the photograph should be marked as viewable by family contacts.</param>
		/// <returns>The id of the photo on a successful upload.</returns>
		/// <exception cref="FlickrException">Thrown when Flickr returns an error. see http://www.flickr.com/services/api/upload.api.html for more details.</exception>
		/// <remarks>Other exceptions may be thrown, see <see cref="FileStream"/> constructors for more details.</remarks>
		public string UploadPicture(string filename, string title, string description, string tags, bool isPublic, bool isFamily, bool isFriend)
		{
			Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
			return UploadPicture(stream, title, description, tags, isPublic?1:0, isFamily?1:0, isFriend?1:0, ContentType.None, SafetyLevel.None, HiddenFromSearch.None);
		}

		/// <summary>
		/// UploadPicture method that does all the uploading work.
		/// </summary>
		/// <param name="stream">The <see cref="Stream"/> object containing the pphoto to be uploaded.</param>
		/// <param name="title">The title of the photo (optional).</param>
		/// <param name="description">The description of the photograph (optional).</param>
		/// <param name="tags">The tags for the photograph (optional).</param>
		/// <param name="isPublic">0 for private, 1 for public.</param>
		/// <param name="isFamily">1 if family, 0 is not.</param>
		/// <param name="isFriend">1 if friend, 0 if not.</param>
		/// <param name="contentType">The content type of the photo, i.e. Photo, Screenshot or Other.</param>
		/// <param name="safetyLevel">The safety level of the photo, i.e. Safe, Moderate or Restricted.</param>
		/// <param name="hiddenFromSearch">Is the photo hidden from public searches.</param>
		/// <returns>The id of the photograph after successful uploading.</returns>
		public string UploadPicture(Stream stream, string title, string description, string tags, int isPublic, int isFamily, int isFriend, ContentType contentType, SafetyLevel safetyLevel, HiddenFromSearch hiddenFromSearch)
		{
			/*
			 * 
			 * Modified UploadPicture code taken from the Flickr.Net library
			 * URL: http://workspaces.gotdotnet.com/flickrdotnet
			 * It is used under the terms of the Common Public License 1.0
			 * URL: http://www.opensource.org/licenses/cpl.php
			 * 
			 * */

			string boundary = "FLICKR_MIME_" + DateTime.Now.ToString("yyyyMMddhhmmss");

			HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(UploadUrl);
			req.UserAgent = "Mozilla/4.0 FlickrNet API (compatible; MSIE 6.0; Windows NT 5.1)";
			req.Method = "POST";
			if( Proxy != null ) req.Proxy = Proxy;
			//req.Referer = "http://www.flickr.com";
			req.KeepAlive = true;
			req.Timeout = HttpTimeout * 1000;
			req.ContentType = "multipart/form-data; boundary=" + boundary + "";
			req.Expect = "";

			StringBuilder sb = new StringBuilder();
            
			Hashtable parameters = new Hashtable();
		
			if( title != null && title.Length > 0 )
			{
				parameters.Add("title", title);
			}
			if( description != null && description.Length > 0 )
			{
				parameters.Add("description", description);
			}
			if( tags != null && tags.Length > 0 )
			{
				parameters.Add("tags", tags);
			}
			if( isPublic >= 0 )
			{
				parameters.Add("is_public", isPublic.ToString());
			}
			if( isFriend >= 0 )
			{
				parameters.Add("is_friend", isFriend.ToString());
			}
			if( isFamily >= 0 )
			{
				parameters.Add("is_family", isFamily.ToString());
			}
			if( safetyLevel != SafetyLevel.None )
			{
				parameters.Add("safety_level", (int)safetyLevel);
			}
			if( contentType != ContentType.None )
			{
				parameters.Add("content_type", (int)contentType);
			}
			if( hiddenFromSearch != HiddenFromSearch.None )
			{
				parameters.Add("hidden", (int)hiddenFromSearch);
			}

			parameters.Add("api_key", _apiKey);
			parameters.Add("auth_token", _apiToken);

			string[] keys = new string[parameters.Keys.Count];
			parameters.Keys.CopyTo(keys, 0);
			Array.Sort(keys);

			StringBuilder HashStringBuilder = new StringBuilder(_sharedSecret, 2 * 1024); 

			foreach(string key in keys)
			{
                HashStringBuilder.Append(key);
                HashStringBuilder.Append(parameters[key]);
				sb.Append("--" + boundary + "\r\n");
				sb.Append("Content-Disposition: form-data; name=\"" + key + "\"\r\n");
				sb.Append("\r\n");
				sb.Append(parameters[key] + "\r\n");
			}

			sb.Append("--" + boundary + "\r\n");
			sb.Append("Content-Disposition: form-data; name=\"api_sig\"\r\n");
			sb.Append("\r\n");
            sb.Append(Md5Hash(HashStringBuilder.ToString()) + "\r\n");

			// Photo
			sb.Append("--" + boundary + "\r\n");
			sb.Append("Content-Disposition: form-data; name=\"photo\"; filename=\"image.jpeg\"\r\n");
			sb.Append("Content-Type: image/jpeg\r\n");
			sb.Append("\r\n");

			UTF8Encoding encoding = new UTF8Encoding();

			byte[] postContents = encoding.GetBytes(sb.ToString());
			
			byte[] photoContents = new byte[stream.Length];
			stream.Read(photoContents, 0, photoContents.Length);
			stream.Close();

			byte[] postFooter = encoding.GetBytes("\r\n--" + boundary + "--\r\n");

			byte[] dataBuffer = new byte[postContents.Length + photoContents.Length + postFooter.Length];
			Buffer.BlockCopy(postContents, 0, dataBuffer, 0, postContents.Length);
			Buffer.BlockCopy(photoContents, 0, dataBuffer, postContents.Length, photoContents.Length);
			Buffer.BlockCopy(postFooter, 0, dataBuffer, postContents.Length + photoContents.Length, postFooter.Length);

			req.ContentLength = dataBuffer.Length;

			Stream resStream = req.GetRequestStream();

			int j = 1;
			int uploadBit = Math.Max(dataBuffer.Length / 100, 50*1024);
			int uploadSoFar = 0;

			for(int i = 0; i < dataBuffer.Length; i=i+uploadBit)
			{
				int toUpload = Math.Min(uploadBit, dataBuffer.Length - i);
				uploadSoFar += toUpload;

				resStream.Write(dataBuffer, i, toUpload);

				if( (OnUploadProgress != null) && ((j++) % 5 == 0 || uploadSoFar == dataBuffer.Length) )
				{
					OnUploadProgress(this, new UploadProgressEventArgs(i+toUpload, uploadSoFar == dataBuffer.Length));
				}
			}
			resStream.Close();

			HttpWebResponse res = (HttpWebResponse)req.GetResponse();

			XmlSerializer serializer = _uploaderSerializer;

			StreamReader sr = new StreamReader(res.GetResponseStream());
			string s= sr.ReadToEnd();
			sr.Close();

			StringReader str = new StringReader(s);

			FlickrNet.Uploader uploader = (FlickrNet.Uploader)serializer.Deserialize(str);
			
			if( uploader.Status == ResponseStatus.OK )
			{
				return uploader.PhotoId;
			}
			else
			{
				throw new FlickrApiException(uploader.Error);
			}
		}

		/// <summary>
		/// Replace an existing photo on Flickr.
		/// </summary>
		/// <param name="filename">The filename of the photo to upload.</param>
		/// <param name="photoId">The ID of the photo to replace.</param>
		/// <returns>The id of the photograph after successful uploading.</returns>
		public string ReplacePicture(string filename, string photoId)
		{
			FileStream stream = null;
			try
			{
				stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
				return ReplacePicture(stream, photoId);
			}
			finally
			{
				if( stream != null ) stream.Close();
			}
			
		}

		/// <summary>
		/// Replace an existing photo on Flickr.
		/// </summary>
		/// <param name="stream">The <see cref="Stream"/> object containing the photo to be uploaded.</param>
		/// <param name="photoId">The ID of the photo to replace.</param>
		/// <returns>The id of the photograph after successful uploading.</returns>
		public string ReplacePicture(Stream stream, string photoId)
		{
			string boundary = "FLICKR_MIME_" + DateTime.Now.ToString("yyyyMMddhhmmss");

			HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(ReplaceUrl);
			req.UserAgent = "Mozilla/4.0 FlickrNet API (compatible; MSIE 6.0; Windows NT 5.1)";
			req.Method = "POST";
			if( Proxy != null ) req.Proxy = Proxy;
			req.Referer = "http://www.flickr.com";
			req.KeepAlive = false;
			req.Timeout = HttpTimeout * 100;
			req.ContentType = "multipart/form-data; boundary=" + boundary + "";

			StringBuilder sb = new StringBuilder();
            
			Hashtable parameters = new Hashtable();
		
			parameters.Add("photo_id", photoId);
			parameters.Add("api_key", _apiKey);
			parameters.Add("auth_token", _apiToken);

			string[] keys = new string[parameters.Keys.Count];
			parameters.Keys.CopyTo(keys, 0);
			Array.Sort(keys);

			StringBuilder HashStringBuilder = new StringBuilder(_sharedSecret, 2 * 1024); 

			foreach(string key in keys)
			{
				HashStringBuilder.Append(key);
				HashStringBuilder.Append(parameters[key]);
				sb.Append("--" + boundary + "\r\n");
				sb.Append("Content-Disposition: form-data; name=\"" + key + "\"\r\n");
				sb.Append("\r\n");
				sb.Append(parameters[key] + "\r\n");
			}

			sb.Append("--" + boundary + "\r\n");
			sb.Append("Content-Disposition: form-data; name=\"api_sig\"\r\n");
			sb.Append("\r\n");
			sb.Append(Md5Hash(HashStringBuilder.ToString()) + "\r\n");

			// Photo
			sb.Append("--" + boundary + "\r\n");
			sb.Append("Content-Disposition: form-data; name=\"photo\"; filename=\"image.jpeg\"\r\n");
			sb.Append("Content-Type: image/jpeg\r\n");
			sb.Append("\r\n");

			UTF8Encoding encoding = new UTF8Encoding();

			byte[] postContents = encoding.GetBytes(sb.ToString());
			
			byte[] photoContents = new byte[stream.Length];
			stream.Read(photoContents, 0, photoContents.Length);
			stream.Close();

			byte[] postFooter = encoding.GetBytes("\r\n--" + boundary + "--\r\n");

			byte[] dataBuffer = new byte[postContents.Length + photoContents.Length + postFooter.Length];
			Buffer.BlockCopy(postContents, 0, dataBuffer, 0, postContents.Length);
			Buffer.BlockCopy(photoContents, 0, dataBuffer, postContents.Length, photoContents.Length);
			Buffer.BlockCopy(postFooter, 0, dataBuffer, postContents.Length + photoContents.Length, postFooter.Length);

			req.ContentLength = dataBuffer.Length;

			Stream resStream = req.GetRequestStream();

			int j = 1;
			int uploadBit = Math.Max(dataBuffer.Length / 100, 50*1024);
			int uploadSoFar = 0;

			for(int i = 0; i < dataBuffer.Length; i=i+uploadBit)
			{
				int toUpload = Math.Min(uploadBit, dataBuffer.Length - i);
				uploadSoFar += toUpload;

				resStream.Write(dataBuffer, i, toUpload);

				if( (OnUploadProgress != null) && ((j++) % 5 == 0 || uploadSoFar == dataBuffer.Length) )
				{
					OnUploadProgress(this, new UploadProgressEventArgs(i+toUpload, uploadSoFar == dataBuffer.Length));
				}
			}
			resStream.Close();

			HttpWebResponse res = (HttpWebResponse)req.GetResponse();

			XmlSerializer serializer = _uploaderSerializer;

			StreamReader sr = new StreamReader(res.GetResponseStream());
			string s= sr.ReadToEnd();
			sr.Close();

			StringReader str = new StringReader(s);

			FlickrNet.Uploader uploader = (FlickrNet.Uploader)serializer.Deserialize(str);
			
			if( uploader.Status == ResponseStatus.OK )
			{
				return uploader.PhotoId;
			}
			else
			{
				throw new FlickrApiException(uploader.Error);
			}
		}
		#endregion

		#region [ Blogs ]
		/// <summary>
		/// Gets a list of blogs that have been set up by the user.
		/// Requires authentication.
		/// </summary>
		/// <returns>A <see cref="Blogs"/> object containing the list of blogs.</returns>
		/// <remarks></remarks>
		public Blogs BlogGetList()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.blogs.getList");
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Blogs;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Posts a photo already uploaded to a blog.
		/// Requires authentication.
		/// </summary>
		/// <param name="blogId">The Id of the blog to post the photo too.</param>
		/// <param name="photoId">The Id of the photograph to post.</param>
		/// <param name="title">The title of the blog post.</param>
		/// <param name="description">The body of the blog post.</param>
		/// <returns>True if the operation is successful.</returns>
		public bool BlogPostPhoto(string blogId, string photoId, string title, string description)
		{
			return BlogPostPhoto(blogId, photoId, title, description, null);
		}

		/// <summary>
		/// Posts a photo already uploaded to a blog.
		/// Requires authentication.
		/// </summary>
		/// <param name="blogId">The Id of the blog to post the photo too.</param>
		/// <param name="photoId">The Id of the photograph to post.</param>
		/// <param name="title">The title of the blog post.</param>
		/// <param name="description">The body of the blog post.</param>
		/// <param name="blogPassword">The password of the blog if it is not already stored in flickr.</param>
		/// <returns>True if the operation is successful.</returns>
		public bool BlogPostPhoto(string blogId, string photoId, string title, string description, string blogPassword)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.blogs.postPhoto");
			parameters.Add("blog_id", blogId);
			parameters.Add("photo_id", photoId);
			parameters.Add("title", title);
			parameters.Add("description", description);
			if( blogPassword != null ) parameters.Add("blog_password", blogPassword);

			FlickrNet.Response response = GetResponseCache(parameters);
			
			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Contacts ]
		/// <summary>
		/// Gets a list of contacts for the logged in user.
		/// Requires authentication.
		/// </summary>
		/// <returns>An instance of the <see cref="Contacts"/> class containing the list of contacts.</returns>
		public Contacts ContactsGetList()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.contacts.getList");
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Contacts;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of the given users contact, or those that are publically avaiable.
		/// </summary>
		/// <param name="userId">The Id of the user who's contacts you want to return.</param>
		/// <returns>An instance of the <see cref="Contacts"/> class containing the list of contacts.</returns>
		public Contacts ContactsGetPublicList(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.contacts.getPublicList");
			parameters.Add("user_id", userId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Contacts;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Favorites ]
		/// <summary>
		/// Adds a photo to the logged in favourites.
		/// Requires authentication.
		/// </summary>
		/// <param name="photoId">The id of the photograph to add.</param>
		/// <returns>True if the operation is successful.</returns>
		public bool FavoritesAdd(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.favorites.add");
			parameters.Add("photo_id", photoId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Removes a photograph from the logged in users favourites.
		/// Requires authentication.
		/// </summary>
		/// <param name="photoId">The id of the photograph to remove.</param>
		/// <returns>True if the operation is successful.</returns>
		public bool FavoritesRemove(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.favorites.remove");
			parameters.Add("photo_id", photoId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get a list of the currently logger in users favourites.
		/// Requires authentication.
		/// </summary>
		/// <returns><see cref="Photos"/> instance containing a collection of <see cref="Photo"/> objects.</returns>
		public Photos FavoritesGetList()
		{
			return FavoritesGetList(null, 0, 0);
		}

		/// <summary>
		/// Get a list of the currently logger in users favourites.
		/// Requires authentication.
		/// </summary>
		/// <param name="perPage">Number of photos to include per page.</param>
		/// <param name="page">The page to download this time.</param>
		/// <returns><see cref="Photos"/> instance containing a collection of <see cref="Photo"/> objects.</returns>
		public Photos FavoritesGetList(int perPage, int page)
		{
			return FavoritesGetList(null, perPage, page);
		}

		/// <summary>
		/// Get a list of favourites for the specified user.
		/// </summary>
		/// <param name="userId">The user id of the user whose favourites you wish to retrieve.</param>
		/// <returns><see cref="Photos"/> instance containing a collection of <see cref="Photo"/> objects.</returns>
		public Photos FavoritesGetList(string userId)
		{
			return FavoritesGetList(userId, 0, 0);
		}

		/// <summary>
		/// Get a list of favourites for the specified user.
		/// </summary>
		/// <param name="userId">The user id of the user whose favourites you wish to retrieve.</param>
		/// <param name="perPage">Number of photos to include per page.</param>
		/// <param name="page">The page to download this time.</param>
		/// <returns><see cref="Photos"/> instance containing a collection of <see cref="Photo"/> objects.</returns>
		public Photos FavoritesGetList(string userId, int perPage, int page)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.favorites.getList");
			if( userId != null ) parameters.Add("user_id", userId);
			if( perPage > 0 ) parameters.Add("per_page", perPage.ToString());
			if( page > 0 ) parameters.Add("page", page.ToString());
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the public favourites for a specified user.
		/// </summary>
		/// <remarks>This function difers from <see cref="Flickr.FavoritesGetList(string)"/> in that the user id 
		/// is not optional.</remarks>
		/// <param name="userId">The is of the user whose favourites you wish to return.</param>
		/// <returns>A <see cref="Photos"/> object containing a collection of <see cref="Photo"/> objects.</returns>
		public Photos FavoritesGetPublicList(string userId)
		{
			return FavoritesGetPublicList(userId, 0, 0);
		}
			
		/// <summary>
		/// Gets the public favourites for a specified user.
		/// </summary>
		/// <remarks>This function difers from <see cref="Flickr.FavoritesGetList(string)"/> in that the user id 
		/// is not optional.</remarks>
		/// <param name="userId">The is of the user whose favourites you wish to return.</param>
		/// <param name="perPage">The number of photos to return per page.</param>
		/// <param name="page">The specific page to return.</param>
		/// <returns>A <see cref="Photos"/> object containing a collection of <see cref="Photo"/> objects.</returns>
		public Photos FavoritesGetPublicList(string userId, int perPage, int page)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.favorites.getPublicList");
			parameters.Add("user_id", userId);
			if( perPage > 0 ) parameters.Add("per_page", perPage.ToString());
			if( page > 0 ) parameters.Add("page", page.ToString());
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Groups ]
		/// <summary>
		/// Returns the top <see cref="Category"/> with a list of sub-categories and groups. 
		/// (The top category does not have any groups in it but others may).
		/// </summary>
		/// <returns>A <see cref="Category"/> instance.</returns>
		public Category GroupsBrowse()
		{
			return GroupsBrowse("0");
		}
		
		/// <summary>
		/// Returns the <see cref="Category"/> specified by the category id with a list of sub-categories and groups. 
		/// </summary>
		/// <param name="catId"></param>
		/// <returns>A <see cref="Category"/> instance.</returns>
		public Category GroupsBrowse(string catId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.browse");
			parameters.Add("cat_id", catId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Category;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Search the list of groups on Flickr for the text.
		/// </summary>
		/// <param name="text">The text to search for.</param>
		/// <returns>A list of groups matching the search criteria.</returns>
		public GroupSearchResults GroupsSearch(string text)
		{
			return GroupsSearch(text, 0, 0);
		}

		/// <summary>
		/// Search the list of groups on Flickr for the text.
		/// </summary>
		/// <param name="text">The text to search for.</param>
		/// <param name="page">The page of the results to return.</param>
		/// <returns>A list of groups matching the search criteria.</returns>
		public GroupSearchResults GroupsSearch(string text, int page)
		{
			return GroupsSearch(text, page, 0);
		}

		/// <summary>
		/// Search the list of groups on Flickr for the text.
		/// </summary>
		/// <param name="text">The text to search for.</param>
		/// <param name="page">The page of the results to return.</param>
		/// <param name="perPage">The number of groups to list per page.</param>
		/// <returns>A list of groups matching the search criteria.</returns>
		public GroupSearchResults GroupsSearch(string text, int page, int perPage)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.search");
			parameters.Add("api_key", _apiKey);
			parameters.Add("text", text);
			if( page > 0 ) parameters.Add("page", page.ToString());
			if( perPage > 0 ) parameters.Add("per_page", perPage.ToString());

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new GroupSearchResults(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a <see cref="GroupFullInfo"/> object containing details about a group.
		/// </summary>
		/// <param name="groupId">The id of the group to return.</param>
		/// <returns>The <see cref="GroupFullInfo"/> specified by the group id.</returns>
		public GroupFullInfo GroupsGetInfo(string groupId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.getInfo");
			parameters.Add("api_key", _apiKey);
			parameters.Add("group_id", groupId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new GroupFullInfo(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Group Pool ]
		/// <summary>
		/// Adds a photo to a pool you have permission to add photos to.
		/// </summary>
		/// <param name="photoId">The id of one of your photos to be added.</param>
		/// <param name="groupId">The id of a group you are a member of.</param>
		/// <returns>True on a successful addition.</returns>
		public bool GroupPoolAdd(string photoId, string groupId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.pools.add");
			parameters.Add("photo_id", photoId);
			parameters.Add("group_id", groupId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the context for a photo from within a group. This provides the
		/// id and thumbnail url for the next and previous photos in the group.
		/// </summary>
		/// <param name="photoId">The Photo ID for the photo you want the context for.</param>
		/// <param name="groupId">The group ID for the group you want the context to be relevant to.</param>
		/// <returns>The <see cref="Context"/> of the photo in the group.</returns>
		public Context GroupPoolGetContext(string photoId, string groupId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.pools.getContext");
			parameters.Add("photo_id", photoId);
			parameters.Add("group_id", groupId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				Context context = new Context();
				context.Count = response.ContextCount.Count;
				context.NextPhoto = response.ContextNextPhoto;
				context.PreviousPhoto = response.ContextPrevPhoto;
				return context;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Remove a picture from a group.
		/// </summary>
		/// <param name="photoId">The id of one of your pictures you wish to remove.</param>
		/// <param name="groupId">The id of the group to remove the picture from.</param>
		/// <returns>True if the photo is successfully removed.</returns>
		public bool GroupPoolRemove(string photoId, string groupId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.pools.remove");
			parameters.Add("photo_id", photoId);
			parameters.Add("group_id", groupId);
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of 
		/// </summary>
		/// <returns></returns>
		public MemberGroupInfo[] GroupPoolGetGroups()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.pools.getGroups");
			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return MemberGroupInfo.GetMemberGroupInfo(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of photos for a given group.
		/// </summary>
		/// <param name="groupId">The group ID for the group.</param>
		/// <returns>A <see cref="Photos"/> object containing the list of photos.</returns>
		public Photos GroupPoolGetPhotos(string groupId)
		{
			return GroupPoolGetPhotos(groupId, null, null, PhotoSearchExtras.All, 0, 0);
		}

		/// <summary>
		/// Gets a list of photos for a given group.
		/// </summary>
		/// <param name="groupId">The group ID for the group.</param>
		/// <param name="tags">Space seperated list of tags that photos returned must have.</param>
		/// <returns>A <see cref="Photos"/> object containing the list of photos.</returns>
		public Photos GroupPoolGetPhotos(string groupId, string tags)
		{
			return GroupPoolGetPhotos(groupId, tags, null, PhotoSearchExtras.All, 0, 0);
		}

		/// <summary>
		/// Gets a list of photos for a given group.
		/// </summary>
		/// <param name="groupId">The group ID for the group.</param>
		/// <param name="perPage">The number of photos per page.</param>
		/// <param name="page">The page to return.</param>
		/// <returns>A <see cref="Photos"/> object containing the list of photos.</returns>
		public Photos GroupPoolGetPhotos(string groupId, int perPage, int page)
		{
			return GroupPoolGetPhotos(groupId, null, null, PhotoSearchExtras.All, perPage, page);
		}

		/// <summary>
		/// Gets a list of photos for a given group.
		/// </summary>
		/// <param name="groupId">The group ID for the group.</param>
		/// <param name="tags">Space seperated list of tags that photos returned must have.</param>
		/// <param name="perPage">The number of photos per page.</param>
		/// <param name="page">The page to return.</param>
		/// <returns>A <see cref="Photos"/> object containing the list of photos.</returns>
		public Photos GroupPoolGetPhotos(string groupId, string tags, int perPage, int page)
		{
			return GroupPoolGetPhotos(groupId, tags, null, PhotoSearchExtras.All, perPage, page);
		}

		/// <summary>
		/// Gets a list of photos for a given group.
		/// </summary>
		/// <param name="groupId">The group ID for the group.</param>
		/// <param name="tags">Space seperated list of tags that photos returned must have.
		/// Currently only supports 1 tag at a time.</param>
		/// <param name="userId">The group member to return photos for.</param>
		/// <param name="extras">The <see cref="PhotoSearchExtras"/> specifying which extras to return. All other overloads default to returning all extras.</param>
		/// <param name="perPage">The number of photos per page.</param>
		/// <param name="page">The page to return.</param>
		/// <returns>A <see cref="Photos"/> object containing the list of photos.</returns>
		public Photos GroupPoolGetPhotos(string groupId, string tags, string userId, PhotoSearchExtras extras, int perPage, int page)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.groups.pools.getPhotos");
			parameters.Add("group_id", groupId);
			if( tags != null && tags.Length > 0 )parameters.Add("tags", tags);
			if( perPage > 0 ) parameters.Add("per_page", perPage.ToString());
			if( page > 0 ) parameters.Add("page", page.ToString());
			if( userId != null && userId.Length > 0 ) parameters.Add("user_id", userId);
			if( extras != PhotoSearchExtras.None ) parameters.Add("extras", Utils.ExtrasToString(extras));

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Interestingness ]
		/// <summary>
		/// Gets a list of photos from the most recent interstingness list.
		/// </summary>
		/// <param name="perPage">Number of photos per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras"><see cref="PhotoSearchExtras"/> enumeration.</param>
		/// <returns><see cref="Photos"/> instance containing list of photos.</returns>
		public Photos InterestingnessGetList(PhotoSearchExtras extras, int perPage, int page)
		{
			return InterestingnessGetList(DateTime.MinValue, extras, perPage, page);
		}

		/// <summary>
		/// Gets a list of photos from the interstingness list for the specified date.
		/// </summary>
		/// <param name="date">The date to return the interestingness list for.</param>
		/// <returns><see cref="Photos"/> instance containing list of photos.</returns>
		public Photos InterestingnessGetList(DateTime date)
		{
			return InterestingnessGetList(date, PhotoSearchExtras.All, 0, 0);
		}

		/// <summary>
		/// Gets a list of photos from the most recent interstingness list.
		/// </summary>
		/// <returns><see cref="Photos"/> instance containing list of photos.</returns>
		public Photos InterestingnessGetList()
		{
			return InterestingnessGetList(DateTime.MinValue, PhotoSearchExtras.All, 0, 0);
		}

		/// <summary>
		/// Gets a list of photos from the most recent interstingness list.
		/// </summary>
		/// <param name="date">The date to return the interestingness photos for.</param>
		/// <param name="extras">The extra parameters to return along with the search results.
		/// See <see cref="PhotoSearchOptions"/> for more details.</param>
		/// <param name="perPage">The number of results to return per page.</param>
		/// <param name="page">The page of the results to return.</param>
		/// <returns></returns>
		public Photos InterestingnessGetList(DateTime date, PhotoSearchExtras extras, int perPage, int page)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.interestingness.getList");

			if( date > DateTime.MinValue ) parameters.Add("date", date.ToString("yyyy-MM-dd"));
			if( perPage > 0 ) parameters.Add("per_page", perPage.ToString());
			if( page > 0 ) parameters.Add("page", page.ToString());
			if( extras != PhotoSearchExtras.None )
				parameters.Add("extras", Utils.ExtrasToString(extras));

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}


		#endregion

		#region [ Notes ]
		/// <summary>
		/// Add a note to a picture.
		/// </summary>
		/// <param name="photoId">The photo id to add the note to.</param>
		/// <param name="noteX">The X co-ordinate of the upper left corner of the note.</param>
		/// <param name="noteY">The Y co-ordinate of the upper left corner of the note.</param>
		/// <param name="noteWidth">The width of the note.</param>
		/// <param name="noteHeight">The height of the note.</param>
		/// <param name="noteText">The text in the note.</param>
		/// <returns></returns>
		public string NotesAdd(string photoId, int noteX, int noteY, int noteWidth, int noteHeight, string noteText)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.notes.add");
			parameters.Add("photo_id", photoId);
			parameters.Add("note_x", noteX.ToString());
			parameters.Add("note_y", noteY.ToString());
			parameters.Add("note_w", noteWidth.ToString());
			parameters.Add("note_h", noteHeight.ToString());
			parameters.Add("note_text", noteText);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				foreach(XmlElement element in response.AllElements)
				{
					return element.Attributes["id", ""].Value;
				}
				return string.Empty;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Edit and update a note.
		/// </summary>
		/// <param name="noteId">The ID of the note to update.</param>
		/// <param name="noteX">The X co-ordinate of the upper left corner of the note.</param>
		/// <param name="noteY">The Y co-ordinate of the upper left corner of the note.</param>
		/// <param name="noteWidth">The width of the note.</param>
		/// <param name="noteHeight">The height of the note.</param>
		/// <param name="noteText">The new text in the note.</param>
		public void NotesEdit(string noteId, int noteX, int noteY, int noteWidth, int noteHeight, string noteText)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.notes.edit");
			parameters.Add("note_id", noteId);
			parameters.Add("note_x", noteX.ToString());
			parameters.Add("note_y", noteY.ToString());
			parameters.Add("note_w", noteWidth.ToString());
			parameters.Add("note_h", noteHeight.ToString());
			parameters.Add("note_text", noteText);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Delete an existing note.
		/// </summary>
		/// <param name="noteId">The ID of the note.</param>
		public void NotesDelete(string noteId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.notes.delete");
			parameters.Add("note_id", noteId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ People ]
		/// <summary>
		/// Used to fid a flickr users details by specifying their email address.
		/// </summary>
		/// <param name="emailAddress">The email address to search on.</param>
		/// <returns>The <see cref="FoundUser"/> object containing the matching details.</returns>
		/// <exception cref="FlickrException">A FlickrException is raised if the email address is not found.</exception>
		public FoundUser PeopleFindByEmail(string emailAddress)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.people.findByEmail");
			parameters.Add("api_key", _apiKey);
			parameters.Add("find_email", emailAddress);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new FoundUser(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a <see cref="FoundUser"/> object matching the screen name.
		/// </summary>
		/// <param name="username">The screen name or username of the user.</param>
		/// <returns>A <see cref="FoundUser"/> class containing the userId and username of the user.</returns>
		/// <exception cref="FlickrException">A FlickrException is raised if the email address is not found.</exception>
		public FoundUser PeopleFindByUsername(string username)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.people.findByUsername");
			parameters.Add("api_key", _apiKey);
			parameters.Add("username", username);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new FoundUser(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the <see cref="Person"/> object for the given user id.
		/// </summary>
		/// <param name="userId">The user id to find.</param>
		/// <returns>The <see cref="Person"/> object containing the users details.</returns>
		public Person PeopleGetInfo(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.people.getInfo");
			parameters.Add("api_key", _apiKey);
			parameters.Add("user_id", userId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return Person.SerializePerson(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the upload status of the authenticated user.
		/// </summary>
		/// <returns>The <see cref="UserStatus"/> object containing the users details.</returns>
		public UserStatus PeopleGetUploadStatus()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.people.getUploadStatus");

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new UserStatus(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get a list of public groups for a user.
		/// </summary>
		/// <param name="userId">The user id to get groups for.</param>
		/// <returns>An array of <see cref="PublicGroupInfo"/> instances.</returns>
		public PublicGroupInfo[] PeopleGetPublicGroups(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.people.getPublicGroups");
			parameters.Add("api_key", _apiKey);
			parameters.Add("user_id", userId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return PublicGroupInfo.GetPublicGroupInfo(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a users public photos. Excludes private photos.
		/// </summary>
		/// <param name="userId">The user id of the user.</param>
		/// <returns>The collection of photos contained within a <see cref="Photo"/> object.</returns>
		public Photos PeopleGetPublicPhotos(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.people.getPublicPhotos");
			parameters.Add("api_key", _apiKey);
			parameters.Add("user_id", userId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Photos ]
		/// <summary>
		/// Add a selection of tags to a photo.
		/// </summary>
		/// <param name="photoId">The photo id of the photo.</param>
		/// <param name="tags">An array of strings containing the tags.</param>
		/// <returns>True if the tags are added successfully.</returns>
		public void PhotosAddTags(string photoId, string[] tags)
		{	
			string s = string.Join(",", tags);
			PhotosAddTags(photoId, s);
		}

		/// <summary>
		/// Add a selection of tags to a photo.
		/// </summary>
		/// <param name="photoId">The photo id of the photo.</param>
		/// <param name="tags">An string of comma delimited tags.</param>
		/// <returns>True if the tags are added successfully.</returns>
		public void PhotosAddTags(string photoId, string tags)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.addTags");
			parameters.Add("photo_id", photoId);
			parameters.Add("tags", tags);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Delete a photo from Flickr.
		/// </summary>
		/// <remarks>
		/// Requires Delete permissions. Also note, photos cannot be recovered once deleted.</remarks>
		/// <param name="photoId">The ID of the photo to delete.</param>
		public void PhotosDelete(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.delete");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get all the contexts (group, set and photostream 'next' and 'previous'
		/// pictures) for a photo.
		/// </summary>
		/// <param name="photoId">The photo id of the photo to get the contexts for.</param>
		/// <returns>An instance of the <see cref="AllContexts"/> class.</returns>
		public AllContexts PhotosGetAllContexts(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getAllContexts");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				AllContexts contexts = new AllContexts(response.AllElements);
				return contexts;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Gets the most recent 10 photos from your contacts.
		/// </summary>
		/// <returns>An instance of the <see cref="Photo"/> class containing the photos.</returns>
		public Photos PhotosGetContactsPhotos()
		{
			return PhotosGetContactsPhotos(0, false, false, false);
		}

		/// <summary>
		/// Gets the most recent photos from your contacts.
		/// </summary>
		/// <remarks>Returns the most recent photos from all your contact, excluding yourself.</remarks>
		/// <param name="count">The number of photos to return, from between 10 and 50.</param>
		/// <returns>An instance of the <see cref="Photo"/> class containing the photos.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// Throws a <see cref="ArgumentOutOfRangeException"/> exception if the cound
		/// is not between 10 and 50, or 0.</exception>
		public Photos PhotosGetContactsPhotos(long count)
		{
			return PhotosGetContactsPhotos(count, false, false, false);
		}

		/// <summary>
		/// Gets your contacts most recent photos.
		/// </summary>
		/// <param name="count">The number of photos to return, from between 10 and 50.</param>
		/// <param name="justFriends">If true only returns photos from contacts marked as
		/// 'friends'.</param>
		/// <param name="singlePhoto">If true only returns a single photo for each of your contacts.
		/// Ignores the count if this is true.</param>
		/// <param name="includeSelf">If true includes yourself in the group of people to 
		/// return photos for.</param>
		/// <returns>An instance of the <see cref="Photo"/> class containing the photos.</returns>
		/// <exception cref="ArgumentOutOfRangeException">
		/// Throws a <see cref="ArgumentOutOfRangeException"/> exception if the cound
		/// is not between 10 and 50, or 0.</exception>
		public Photos PhotosGetContactsPhotos(long count, bool justFriends, bool singlePhoto, bool includeSelf)
		{
			if( count != 0 && (count < 10 || count > 50) && !singlePhoto )
			{
				throw new ArgumentOutOfRangeException("count", String.Format("Count must be between 10 and 50. ({0})", count));
			}
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getContactsPhotos");
			if( count > 0 && !singlePhoto ) parameters.Add("count", count.ToString());
			if( justFriends ) parameters.Add("just_friends", "1");
			if( singlePhoto ) parameters.Add("single_photo", "1");
			if( includeSelf ) parameters.Add("include_self", "1");

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the public photos for given users ID's contacts.
		/// </summary>
		/// <param name="userId">The user ID whose contacts you wish to get photos for.</param>
		/// <returns>A <see cref="Photos"/> object containing details of the photos returned.</returns>
		public Photos PhotosGetContactsPublicPhotos(string userId)
		{
			return PhotosGetContactsPublicPhotos(userId, 0, false, false, false, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Gets the public photos for given users ID's contacts.
		/// </summary>
		/// <param name="userId">The user ID whose contacts you wish to get photos for.</param>
		/// <param name="extras">A list of extra details to return for each photo.</param>
		/// <returns>A <see cref="Photos"/> object containing details of the photos returned.</returns>
		public Photos PhotosGetContactsPublicPhotos(string userId, PhotoSearchExtras extras)
		{
			return PhotosGetContactsPublicPhotos(userId, 0, false, false, false, extras);
		}

		/// <summary>
		/// Gets the public photos for given users ID's contacts.
		/// </summary>
		/// <param name="userId">The user ID whose contacts you wish to get photos for.</param>
		/// <param name="count">The number of photos to return. Defaults to 10, maximum is 50.</param>
		/// <returns>A <see cref="Photos"/> object containing details of the photos returned.</returns>
		public Photos PhotosGetContactsPublicPhotos(string userId, long count)
		{
			return PhotosGetContactsPublicPhotos(userId, count, false, false, false, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Gets the public photos for given users ID's contacts.
		/// </summary>
		/// <param name="userId">The user ID whose contacts you wish to get photos for.</param>
		/// <param name="count">The number of photos to return. Defaults to 10, maximum is 50.</param>
		/// <param name="extras">A list of extra details to return for each photo.</param>
		/// <returns>A <see cref="Photos"/> object containing details of the photos returned.</returns>
		public Photos PhotosGetContactsPublicPhotos(string userId, long count, PhotoSearchExtras extras)
		{
			return PhotosGetContactsPublicPhotos(userId, count, false, false, false, extras);
		}

		/// <summary>
		/// Gets the public photos for given users ID's contacts.
		/// </summary>
		/// <param name="userId">The user ID whose contacts you wish to get photos for.</param>
		/// <param name="count">The number of photos to return. Defaults to 10, maximum is 50.</param>
		/// <param name="justFriends">True to just return photos from friends and family (excluding regular contacts).</param>
		/// <param name="singlePhoto">True to return just a single photo for each contact.</param>
		/// <param name="includeSelf">True to include photos from the user ID specified as well.</param>
		/// <returns></returns>
		public Photos PhotosGetContactsPublicPhotos(string userId, long count, bool justFriends, bool singlePhoto, bool includeSelf)
		{
			return PhotosGetContactsPublicPhotos(userId, count, justFriends, singlePhoto, includeSelf, PhotoSearchExtras.All);
		}
			
		/// <summary>
		/// Gets the public photos for given users ID's contacts.
		/// </summary>
		/// <param name="userId">The user ID whose contacts you wish to get photos for.</param>
		/// <param name="count">The number of photos to return. Defaults to 10, maximum is 50.</param>
		/// <param name="justFriends">True to just return photos from friends and family (excluding regular contacts).</param>
		/// <param name="singlePhoto">True to return just a single photo for each contact.</param>
		/// <param name="includeSelf">True to include photos from the user ID specified as well.</param>
		/// <param name="extras">A list of extra details to return for each photo.</param>
		/// <returns></returns>
		public Photos PhotosGetContactsPublicPhotos(string userId, long count, bool justFriends, bool singlePhoto, bool includeSelf, PhotoSearchExtras extras)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getContactsPublicPhotos");
			parameters.Add("api_key", _apiKey);
			parameters.Add("user_id", userId);
			if( count > 0 ) parameters.Add("count", count.ToString());
			if( justFriends ) parameters.Add("just_friends", "1");
			if( singlePhoto ) parameters.Add("single_photo", "1");
			if( includeSelf ) parameters.Add("include_self", "1");
			if( extras != PhotoSearchExtras.None ) parameters.Add("extras", Utils.ExtrasToString(extras));

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the context of the photo in the users photostream.
		/// </summary>
		/// <param name="photoId">The ID of the photo to return the context for.</param>
		/// <returns></returns>
		public Context PhotosGetContext(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getContext");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				Context c = new Context();
				c.Count = response.ContextCount.Count;
				c.NextPhoto = response.ContextNextPhoto;
				c.PreviousPhoto = response.ContextPrevPhoto;

				return c;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns count of photos between each pair of dates in the list.
		/// </summary>
		/// <remarks>If you pass in DateA, DateB and DateC it returns
		/// a list of the number of photos between DateA and DateB,
		/// followed by the number between DateB and DateC. 
		/// More parameters means more sets.</remarks>
		/// <param name="dates">Array of <see cref="DateTime"/> objects.</param>
		/// <returns><see cref="PhotoCounts"/> class instance.</returns>
		public PhotoCounts PhotosGetCounts(DateTime[] dates)
		{
			return PhotosGetCounts(dates, false);
		}

		/// <summary>
		/// Returns count of photos between each pair of dates in the list.
		/// </summary>
		/// <remarks>If you pass in DateA, DateB and DateC it returns
		/// a list of the number of photos between DateA and DateB,
		/// followed by the number between DateB and DateC. 
		/// More parameters means more sets.</remarks>
		/// <param name="dates">Array of <see cref="DateTime"/> objects.</param>
		/// <param name="taken">Boolean parameter to specify if the dates are the taken date, or uploaded date.</param>
		/// <returns><see cref="PhotoCounts"/> class instance.</returns>
		public PhotoCounts PhotosGetCounts(DateTime[] dates, bool taken)
		{
			StringBuilder s = new StringBuilder(dates.Length * 20);
			foreach(DateTime d in dates)
			{
				s.Append(Utils.DateToUnixTimestamp(d));
				s.Append(",");
			}
			if( s.Length > 0 ) s.Remove(s.Length-2,1);

			if( taken )
                return PhotosGetCounts(null, s.ToString());
			else
				return PhotosGetCounts(s.ToString(), null);
		}
		/// <summary>
		/// Returns count of photos between each pair of dates in the list.
		/// </summary>
		/// <remarks>If you pass in DateA, DateB and DateC it returns
		/// a list of the number of photos between DateA and DateB,
		/// followed by the number between DateB and DateC. 
		/// More parameters means more sets.</remarks>
		/// <param name="dates">Comma-delimited list of dates in unix timestamp format. Optional.</param>
		/// <returns><see cref="PhotoCounts"/> class instance.</returns>
		public PhotoCounts PhotosGetCounts(string dates)
		{
			return PhotosGetCounts(dates, null);
		}

		/// <summary>
		/// Returns count of photos between each pair of dates in the list.
		/// </summary>
		/// <remarks>If you pass in DateA, DateB and DateC it returns
		/// a list of the number of photos between DateA and DateB,
		/// followed by the number between DateB and DateC. 
		/// More parameters means more sets.</remarks>
		/// <param name="dates">Comma-delimited list of dates in unix timestamp format. Optional.</param>
		/// <param name="taken_dates">Comma-delimited list of dates in unix timestamp format. Optional.</param>
		/// <returns><see cref="PhotoCounts"/> class instance.</returns>
		public PhotoCounts PhotosGetCounts(string dates, string taken_dates)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getContactsPhotos");
			if( dates != null && dates.Length > 0 ) parameters.Add("dates", dates);
			if( taken_dates != null && taken_dates.Length > 0 ) parameters.Add("taken_dates", taken_dates);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.PhotoCounts;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the EXIF data for a given Photo ID.
		/// </summary>
		/// <param name="photoId">The Photo ID of the photo to return the EXIF data for.</param>
		/// <returns>An instance of the <see cref="ExifPhoto"/> class containing the EXIF data.</returns>
		public ExifPhoto PhotosGetExif(string photoId)
		{
			return PhotosGetExif(photoId, null);
		}

		/// <summary>
		/// Gets the EXIF data for a given Photo ID.
		/// </summary>
		/// <param name="photoId">The Photo ID of the photo to return the EXIF data for.</param>
		/// <param name="secret">The secret of the photo. If the secret is specified then
		/// authentication checks are bypassed.</param>
		/// <returns>An instance of the <see cref="ExifPhoto"/> class containing the EXIF data.</returns>
		public ExifPhoto PhotosGetExif(string photoId, string secret)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getExif");
			parameters.Add("photo_id", photoId);
			if( secret != null ) parameters.Add("secret", secret);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				ExifPhoto e = new ExifPhoto(response.PhotoInfo.PhotoId,
					response.PhotoInfo.Secret,
					response.PhotoInfo.Server,
					response.PhotoInfo.ExifTagCollection);

				return e;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get information about a photo. The calling user must have permission to view the photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to fetch information for.</param>
		/// <returns>A <see cref="PhotoInfo"/> class detailing the properties of the photo.</returns>
		public PhotoInfo PhotosGetInfo(string photoId)
		{
			return PhotosGetInfo(photoId, null);
		}
		
		/// <summary>
		/// Get information about a photo. The calling user must have permission to view the photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to fetch information for.</param>
		/// <param name="secret">The secret for the photo. If the correct secret is passed then permissions checking is skipped. This enables the 'sharing' of individual photos by passing around the id and secret.</param>
		/// <returns>A <see cref="PhotoInfo"/> class detailing the properties of the photo.</returns>
		public PhotoInfo PhotosGetInfo(string photoId, string secret)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getInfo");
			parameters.Add("photo_id", photoId);
			if( secret != null ) parameters.Add("secret", secret);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.PhotoInfo;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get permissions for a photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to get permissions for.</param>
		/// <returns>An instance of the <see cref="PhotoPermissions"/> class containing the permissions of the specified photo.</returns>
		public PhotoPermissions PhotosGetPerms(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getPerms");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new PhotoPermissions(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a list of the latest public photos uploaded to flickr.
		/// </summary>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetRecent()
		{
			return PhotosGetRecent(0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Returns a list of the latest public photos uploaded to flickr.
		/// </summary>
		/// <param name="extras">A comma-delimited list of extra information to fetch for each returned record.</param>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetRecent(PhotoSearchExtras extras)
		{
			return PhotosGetRecent(0, 0, extras);
		}

		/// <summary>
		/// Returns a list of the latest public photos uploaded to flickr.
		/// </summary>
		/// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
		/// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.</param>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetRecent(long perPage, long page)
		{
			return PhotosGetRecent(perPage, page, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Returns a list of the latest public photos uploaded to flickr.
		/// </summary>
		/// <param name="extras">A comma-delimited list of extra information to fetch for each returned record.</param>
		/// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
		/// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.</param>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetRecent(long perPage, long page, PhotoSearchExtras extras)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getRecent");
			parameters.Add("api_key", _apiKey);
			if( perPage > 0 ) parameters.Add("per_page", perPage.ToString());
			if( page > 0 ) parameters.Add("page", page.ToString());
			if( extras != PhotoSearchExtras.None ) parameters.Add("extras", Utils.ExtrasToString(extras));

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns the available sizes for a photo. The calling user must have permission to view the photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to fetch size information for.</param>
		/// <returns>A <see cref="Sizes"/> class whose property <see cref="Sizes.SizeCollection"/> is an array of <see cref="Size"/> objects.</returns>
		public Sizes PhotosGetSizes(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getSizes");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Sizes;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a list of your photos with no tags.
		/// </summary>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetUntagged()
		{
			return PhotosGetUntagged(0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Returns a list of your photos with no tags.
		/// </summary>
		/// <param name="extras">A comma-delimited list of extra information to fetch for each returned record.</param>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetUntagged(PhotoSearchExtras extras)
		{
			return PhotosGetUntagged(0, 0, extras);
		}

		/// <summary>
		/// Returns a list of your photos with no tags.
		/// </summary>
		/// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
		/// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.</param>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetUntagged(int perPage, int page)
		{
			return PhotosGetUntagged(perPage, page, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Returns a list of your photos with no tags.
		/// </summary>
		/// <param name="extras">A comma-delimited list of extra information to fetch for each returned record.</param>
		/// <param name="page">The page of results to return. If this argument is omitted, it defaults to 1.</param>
		/// <param name="perPage">Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.</param>
		/// <returns>A <see cref="Photos"/> class containing the list of photos.</returns>
		public Photos PhotosGetUntagged(int perPage, int page, PhotoSearchExtras extras)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getUntagged");
			if( perPage > 0 ) parameters.Add("per_page", perPage.ToString());
			if( page > 0 ) parameters.Add("page", page.ToString());
			if( extras != PhotoSearchExtras.None ) parameters.Add("extras", Utils.ExtrasToString(extras));

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of photos not in sets. Defaults to include all extra fields.
		/// </summary>
		/// <returns><see cref="Photos"/> instance containing list of photos.</returns>
		public Photos PhotosGetNotInSet()
		{
			return PhotosGetNotInSet(new PartialSearchOptions());
		}

		/// <summary>
		/// Gets a specific page of the list of photos which are not in sets.
		/// Defaults to include all extra fields.
		/// </summary>
		/// <param name="page">The page number to return.</param>
		/// <returns><see cref="Photos"/> instance containing list of photos.</returns>
		public Photos PhotosGetNotInSet(int page)
		{
			return PhotosGetNotInSet(0, page, PhotoSearchExtras.None);
		}

		/// <summary>
		/// Gets a specific page of the list of photos which are not in sets.
		/// Defaults to include all extra fields.
		/// </summary>
		/// <param name="perPage">Number of photos per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <returns><see cref="Photos"/> instance containing list of photos.</returns>
		public Photos PhotosGetNotInSet(int perPage, int page)
		{
			return PhotosGetNotInSet(perPage, page, PhotoSearchExtras.None);
		}

		/// <summary>
		/// Gets a list of a users photos which are not in a set.
		/// </summary>
		/// <param name="perPage">Number of photos per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras"><see cref="PhotoSearchExtras"/> enumeration.</param>
		/// <returns><see cref="Photos"/> instance containing list of photos.</returns>
		public Photos PhotosGetNotInSet(int perPage, int page, PhotoSearchExtras extras)
		{
			PartialSearchOptions options = new PartialSearchOptions();
			options.PerPage = perPage;
			options.Page = page;
			options.Extras = extras;

			return PhotosGetNotInSet(options);
		}

		/// <summary>
		/// Gets a list of the authenticated users photos which are not in a set.
		/// </summary>
		/// <param name="options">A selection of options to filter/sort by.</param>
		/// <returns>A collection of photos in the <see cref="Photos"/> class.</returns>
		public Photos PhotosGetNotInSet(PartialSearchOptions options)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getNotInSet");
			Utils.PartialOptionsIntoArray(options, parameters);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of all current licenses.
		/// </summary>
		/// <returns><see cref="Licenses"/> instance.</returns>
		public Licenses PhotosLicensesGetInfo()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.licenses.getInfo");
			parameters.Add("api_key", _apiKey);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Licenses;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Remove an existing tag.
		/// </summary>
		/// <param name="tagId">The id of the tag, as returned by <see cref="Flickr.PhotosGetInfo(string)"/> or similar method.</param>
		/// <returns>True if the tag was removed.</returns>
		public bool PhotosRemoveTag(string tagId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.removeTag");
			parameters.Add("tag_id", tagId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="userId">The user whose photos you wish to search for.</param>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string userId, string text)
		{
			return PhotosSearch(userId, "", 0, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="userId">The user whose photos you wish to search for.</param>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string userId, string text, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, "", 0, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="userId">The user whose photos you wish to search for.</param>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <param name="license">The license type to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string userId, string text, int license)
		{
			return PhotosSearch(userId, "", 0, text, DateTime.MinValue, DateTime.MinValue, license, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="userId">The user whose photos you wish to search for.</param>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string userId, string text, int license, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, "", 0, text, DateTime.MinValue, DateTime.MinValue, license, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string text, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, "", 0, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string text)
		{
			return PhotosSearch(null, "", 0, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <param name="license">The license type to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string text, int license)
		{
			return PhotosSearch(null, "", 0, text, DateTime.MinValue, DateTime.MinValue, license, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos containing text, rather than tags.
		/// </summary>
		/// <param name="text">The text you want to search for in titles and descriptions.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearchText(string text, int license, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, "", 0, text, DateTime.MinValue, DateTime.MinValue, license, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos containing an array of tags.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, tags, 0, "", DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos containing an array of tags.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags)
		{
			return PhotosSearch(null, tags, 0, "", DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos containing an array of tags.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags, int license, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos containing an array of tags.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags, int license)
		{
			return PhotosSearch(null, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags, TagMode tagMode, string text, int perPage, int page)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags, TagMode tagMode, string text, int perPage, int page, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags, TagMode tagMode, string text)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string[] tags, TagMode tagMode, string text, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, int license)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, int license, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, TagMode tagMode, string text, int perPage, int page)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, TagMode tagMode, string text, int perPage, int page, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, TagMode tagMode, string text)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, TagMode tagMode, string text, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="minUploadDate">The minimum upload date.</param>
		/// <param name="maxUploadDate">The maxmimum upload date.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, TagMode tagMode, string text, DateTime minUploadDate, DateTime maxUploadDate, int license, int perPage, int page, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, String.Join(",", tags), tagMode, text, minUploadDate, maxUploadDate, license, perPage, page, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">An array of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="minUploadDate">The minimum upload date.</param>
		/// <param name="maxUploadDate">The maxmimum upload date.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string[] tags, TagMode tagMode, string text, DateTime minUploadDate, DateTime maxUploadDate, int license, int perPage, int page)
		{
			return PhotosSearch(userId, String.Join(",", tags), tagMode, text, minUploadDate, maxUploadDate, license, perPage, page, PhotoSearchExtras.All);
		}

		// PhotoSearch - tags versions

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string tags, int license, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string tags, int license)
		{
			return PhotosSearch(null, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string tags, TagMode tagMode, string text, int perPage, int page)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string tags, TagMode tagMode, string text, int perPage, int page, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string tags, TagMode tagMode, string text)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string tags, TagMode tagMode, string text, PhotoSearchExtras extras)
		{
			return PhotosSearch(null, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, int license)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="license">The license type to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, int license, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, 0, "", DateTime.MinValue, DateTime.MinValue, license, 0, 0, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text, int perPage, int page)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text, int perPage, int page, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, perPage, page, extras);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, PhotoSearchExtras.All);
		}

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text, PhotoSearchExtras extras)
		{
			return PhotosSearch(userId, tags, tagMode, text, DateTime.MinValue, DateTime.MinValue, 0, 0, 0, extras);
		}

		// Actual PhotoSearch function

		/// <summary>
		/// Search for photos.
		/// </summary>
		/// <param name="userId">The ID of the user to search the photos of.</param>
		/// <param name="tags">A comma seperated list of tags to search for.</param>
		/// <param name="tagMode">Match all tags, or any tag.</param>
		/// <param name="text">Text to search for in photo title or description.</param>
		/// <param name="perPage">Number of photos to return per page.</param>
		/// <param name="page">The page number to return.</param>
		/// <param name="extras">Optional extras to return.</param>
		/// <param name="minUploadDate">The minimum upload date.</param>
		/// <param name="maxUploadDate">The maxmimum upload date.</param>
		/// <param name="license">The license type to return.</param>
		/// <returns>A <see cref="Photos"/> instance.</returns>
		public Photos PhotosSearch(string userId, string tags, TagMode tagMode, string text, DateTime minUploadDate, DateTime maxUploadDate, int license, int perPage, int page, PhotoSearchExtras extras)
		{
			PhotoSearchOptions options = new PhotoSearchOptions();
			options.UserId = userId;
			options.Tags = tags;
			options.TagMode = tagMode;
			options.Text = text;
			options.MinUploadDate = minUploadDate;
			options.MaxUploadDate = maxUploadDate;
			if( license > 0 ) options.AddLicense(license);
			options.PerPage = perPage;
			options.Page = page;
			options.Extras = extras;

			return PhotosSearch(options);
		}

		/// <summary>
		/// Search for a set of photos, based on the value of the <see cref="PhotoSearchOptions"/> parameters.
		/// </summary>
		/// <param name="options">The parameters to search for.</param>
		/// <returns>A collection of photos contained within a <see cref="Photos"/> object.</returns>
		public Photos PhotosSearch(PhotoSearchOptions options)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.search");
			if( options.UserId != null && options.UserId.Length > 0 ) parameters.Add("user_id", options.UserId);
			if( options.GroupId != null && options.GroupId.Length > 0 ) parameters.Add("group_id", options.GroupId);
			if( options.Text != null && options.Text.Length > 0 ) parameters.Add("text", options.Text);
			if( options.Tags != null && options.Tags.Length > 0 ) parameters.Add("tags", options.Tags);
			if( options.TagMode != TagMode.None ) parameters.Add("tag_mode", options.TagModeString);
			if( options.MachineTags != null && options.MachineTags.Length > 0 ) parameters.Add("machine_tags", options.MachineTags);
			if( options.MachineTagMode != MachineTagMode.None ) parameters.Add("machine_tag_mode", options.MachineTagModeString);
			if( options.MinUploadDate != DateTime.MinValue ) parameters.Add("min_upload_date", Utils.DateToUnixTimestamp(options.MinUploadDate).ToString());
			if( options.MaxUploadDate != DateTime.MinValue ) parameters.Add("max_upload_date", Utils.DateToUnixTimestamp(options.MaxUploadDate).ToString());
			if( options.MinTakenDate != DateTime.MinValue ) parameters.Add("min_taken_date", options.MinTakenDate.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
			if( options.MaxTakenDate != DateTime.MinValue ) parameters.Add("max_taken_date", options.MaxTakenDate.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
			if( options.Licenses.Length != 0 ) 
			{
				string lic = "";
				for(int i = 0; i < options.Licenses.Length; i++)
				{
					if( i > 0 ) lic += ",";
					lic += Convert.ToString(options.Licenses[i]);
				}
				parameters.Add("license", lic);
			}
			if( options.PerPage != 0 ) parameters.Add("per_page", options.PerPage.ToString());
			if( options.Page != 0 ) parameters.Add("page", options.Page.ToString());
			if( options.Extras != PhotoSearchExtras.None ) parameters.Add("extras", options.ExtrasString);
			if( options.SortOrder != PhotoSearchSortOrder.None ) parameters.Add("sort", options.SortOrderString);
			if( options.PrivacyFilter != PrivacyFilter.None ) parameters.Add("privacy_filter", options.PrivacyFilter.ToString("d"));
			if( options.BoundaryBox.IsSet ) parameters.Add("bbox", options.BoundaryBox.ToString());
			if( options.Accuracy != GeoAccuracy.None ) parameters.Add("accuracy", options.Accuracy.ToString("d"));

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Set the date taken for a photo.
		/// </summary>
		/// <remarks>
		/// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
		/// timezone.
		/// </remarks>
		/// <param name="photoId">The id of the photo to set the date taken for.</param>
		/// <param name="dateTaken">The date taken.</param>
		/// <param name="granularity">The granularity of the date taken.</param>
		/// <returns>True if the date was updated successfully.</returns>
		public bool PhotosSetDates(string photoId, DateTime dateTaken, DateGranularity granularity)
		{
			return PhotosSetDates(photoId, DateTime.MinValue, dateTaken, granularity);
		}
		
		/// <summary>
		/// Set the date the photo was posted (uploaded). This will affect the order in which photos
		/// are seen in your photostream.
		/// </summary>
		/// <remarks>
		/// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
		/// timezone.
		/// </remarks>
		/// <param name="photoId">The id of the photo to set the date posted.</param>
		/// <param name="datePosted">The new date to set the date posted too.</param>
		/// <returns>True if the date was updated successfully.</returns>
		public bool PhotosSetDates(string photoId, DateTime datePosted)
		{
			return PhotosSetDates(photoId, datePosted, DateTime.MinValue, DateGranularity.FullDate);
		}
		
		/// <summary>
		/// Set the date the photo was posted (uploaded) and the date the photo was taken.
		/// Changing the date posted will affect the order in which photos are seen in your photostream.
		/// </summary>
		/// <remarks>
		/// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
		/// timezone.
		/// </remarks>
		/// <param name="photoId">The id of the photo to set the dates.</param>
		/// <param name="datePosted">The new date to set the date posted too.</param>
		/// <param name="dateTaken">The new date to set the date taken too.</param>
		/// <param name="granularity">The granularity of the date taken.</param>
		/// <returns>True if the dates where updated successfully.</returns>
		public bool PhotosSetDates(string photoId, DateTime datePosted, DateTime dateTaken, DateGranularity granularity)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.setDates");
			parameters.Add("photo_id", photoId);
			if( datePosted != DateTime.MinValue ) parameters.Add("date_posted", Utils.DateToUnixTimestamp(datePosted).ToString());
			if( dateTaken != DateTime.MinValue ) 
			{
				parameters.Add("date_taken", dateTaken.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
				parameters.Add("date_taken_granularity", granularity.ToString("d"));
			}

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Sets the title and description of the photograph.
		/// </summary>
		/// <param name="photoId">The numerical photoId of the photograph.</param>
		/// <param name="title">The new title of the photograph.</param>
		/// <param name="description">The new description of the photograph.</param>
		/// <returns>True when the operation is successful.</returns>
		/// <exception cref="FlickrException">Thrown when the photo id cannot be found.</exception>
		public bool PhotosSetMeta(string photoId, string title, string description)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.setMeta");
			parameters.Add("photo_id", photoId);
			parameters.Add("title", title);
			parameters.Add("description", description);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Set the permissions on a photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to update.</param>
		/// <param name="isPublic">1 if the photo is public, 0 if it is not.</param>
		/// <param name="isFriend">1 if the photo is viewable by friends, 0 if it is not.</param>
		/// <param name="isFamily">1 if the photo is viewable by family, 0 if it is not.</param>
		/// <param name="permComment">Who can add comments. See <see cref="PermissionComment"/> for more details.</param>
		/// <param name="permAddMeta">Who can add metadata (notes and tags). See <see cref="PermissionAddMeta"/> for more details.</param>
		public void PhotosSetPerms(string photoId, int isPublic, int isFriend, int isFamily, PermissionComment permComment, PermissionAddMeta permAddMeta)
		{
			PhotosSetPerms(photoId, (isPublic==1), (isFriend==1), (isFamily==1), permComment, permAddMeta);
		}

		/// <summary>
		/// Set the permissions on a photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to update.</param>
		/// <param name="isPublic">True if the photo is public, False if it is not.</param>
		/// <param name="isFriend">True if the photo is viewable by friends, False if it is not.</param>
		/// <param name="isFamily">True if the photo is viewable by family, False if it is not.</param>
		/// <param name="permComment">Who can add comments. See <see cref="PermissionComment"/> for more details.</param>
		/// <param name="permAddMeta">Who can add metadata (notes and tags). See <see cref="PermissionAddMeta"/> for more details.</param>
		public void PhotosSetPerms(string photoId, bool isPublic, bool isFriend, bool isFamily, PermissionComment permComment, PermissionAddMeta permAddMeta)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.setPerms");
			parameters.Add("photo_id", photoId);
			parameters.Add("is_public", (isPublic?"1":"0"));
			parameters.Add("is_friend", (isFriend?"1":"0"));
			parameters.Add("is_family", (isFamily?"1":"0"));
			parameters.Add("perm_comment", permComment.ToString("d"));
			parameters.Add("perm_addmeta", permAddMeta.ToString("d"));

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Set the tags for a photo.
		/// </summary>
		/// <remarks>
		/// This will remove all old tags and add these new ones specified. See <see cref="PhotosAddTags(string, string)"/>
		/// to just add new tags without deleting old ones.
		/// </remarks>
		/// <param name="photoId">The id of the photo to update.</param>
		/// <param name="tags">An array of tags.</param>
		/// <returns>True if the photo was updated successfully.</returns>
		public bool PhotosSetTags(string photoId, string[] tags)
		{
			string s = string.Join(",", tags);
			return PhotosSetTags(photoId, s);
		}
			
		/// <summary>
		/// Set the tags for a photo.
		/// </summary>
		/// <remarks>
		/// This will remove all old tags and add these new ones specified. See <see cref="PhotosAddTags(string, string)"/>
		/// to just add new tags without deleting old ones.
		/// </remarks>
		/// <param name="photoId">The id of the photo to update.</param>
		/// <param name="tags">An comma-seperated list of tags.</param>
		/// <returns>True if the photo was updated successfully.</returns>
		public bool PhotosSetTags(string photoId, string tags)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.setTags");
			parameters.Add("photo_id", photoId);
			parameters.Add("tags", tags);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Sets the content type for a photo.
		/// </summary>
		/// <param name="photoId">The ID of the photos to set.</param>
		/// <param name="contentType">The new content type.</param>
		public void PhotosSetContentType(string photoId, ContentType contentType)
		{
			CheckRequiresAuthentication();

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.setContentType");
			parameters.Add("photo_id", photoId);
			parameters.Add("content_type", (int)contentType);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Set the safety level for a photo, but only set the hidden aspect.
		/// </summary>
		/// <param name="photoId">The ID of the photo to set the hidden property for.</param>
		/// <param name="hidden">The new value of the hidden value.</param>
		public void PhotosSetSafetyLevel(string photoId, HiddenFromSearch hidden)
		{
			PhotosSetSafetyLevel(photoId, SafetyLevel.None, hidden);
		}

		/// <summary>
		/// Set the safety level for a photo.
		/// </summary>
		/// <param name="photoId">The ID of the photo to set the safety level property for.</param>
		/// <param name="safetyLevel">The new value of the safety level value.</param>
		public void PhotosSetSafetyLevel(string photoId, SafetyLevel safetyLevel)
		{
			PhotosSetSafetyLevel(photoId, safetyLevel, HiddenFromSearch.None);
		}

		/// <summary>
		/// Sets the safety level and hidden property of a photo.
		/// </summary>
		/// <param name="photoId">The ID of the photos to set.</param>
		/// <param name="safetyLevel">The new content type.</param>
		/// <param name="hidden">The new hidden value.</param>
		public void PhotosSetSafetyLevel(string photoId, SafetyLevel safetyLevel, HiddenFromSearch hidden)
		{
			CheckRequiresAuthentication();

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.setSafetyLevel");
			parameters.Add("photo_id", photoId);
			if( safetyLevel != SafetyLevel.None ) parameters.Add("safety_level", (int)safetyLevel);
			switch(hidden)
			{
				case HiddenFromSearch.Visible:
					parameters.Add("hidden", 0);
					break;
				case HiddenFromSearch.Hidden:
					parameters.Add("hidden", 1);
					break;
			}

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Photos Comments ]
		/// <summary>
		/// Gets a list of comments for a photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to return the comments for.</param>
		/// <returns>An array of <see cref="Comment"/> objects.</returns>
		public Comment[] PhotosCommentsGetList(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.comments.getList");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return PhotoComments.GetComments(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Adds a new comment to a photo.
		/// </summary>
		/// <param name="photoId">The ID of the photo to add the comment to.</param>
		/// <param name="commentText">The text of the comment. Can contain some HTML.</param>
		/// <returns>The new ID of the created comment.</returns>
		public string PhotosCommentsAddComment(string photoId, string commentText)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.comments.addComment");
			parameters.Add("photo_id", photoId);
			parameters.Add("comment_text", commentText);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				XmlNode node = response.AllElements[0];
				if( node.Attributes.GetNamedItem("id") != null )
					return node.Attributes.GetNamedItem("id").Value;
				else
					throw new ResponseXmlException("Comment ID not found in response Xml.");
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Deletes a comment from a photo.
		/// </summary>
		/// <param name="commentId">The ID of the comment to delete.</param>
		public void PhotosCommentsDeleteComment(string commentId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.comments.deleteComment");
			parameters.Add("comment_id", commentId);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Edits a comment.
		/// </summary>
		/// <param name="commentId">The ID of the comment to edit.</param>
		/// <param name="commentText">The new text for the comment.</param>
		public void PhotosCommentsEditComment(string commentId, string commentText)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.comments.editComment");
			parameters.Add("comment_id", commentId);
			parameters.Add("comment_text", commentText);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Photosets ]
		/// <summary>
		/// Add a photo to a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to add the photo to.</param>
		/// <param name="photoId">The ID of the photo to add.</param>
		public void PhotosetsAddPhoto(string photosetId, string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.addPhoto");
			parameters.Add("photoset_id", photosetId);
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Creates a blank photoset, with a title and a primary photo (minimum requirements).
		/// </summary>
		/// <param name="title">The title of the photoset.</param>
		/// <param name="primaryPhotoId">The ID of the photo which will be the primary photo for the photoset. This photo will also be added to the set.</param>
		/// <returns>The <see cref="Photoset"/> that is created.</returns>
		public Photoset PhotosetsCreate(string title, string primaryPhotoId)
		{
			return PhotosetsCreate(title, null, primaryPhotoId);
		}

		/// <summary>
		/// Creates a blank photoset, with a title, description and a primary photo.
		/// </summary>
		/// <param name="title">The title of the photoset.</param>
		/// <param name="description">THe description of the photoset.</param>
		/// <param name="primaryPhotoId">The ID of the photo which will be the primary photo for the photoset. This photo will also be added to the set.</param>
		/// <returns>The <see cref="Photoset"/> that is created.</returns>
		public Photoset PhotosetsCreate(string title, string description, string primaryPhotoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.create");
			parameters.Add("title", title);
			parameters.Add("primary_photo_id", primaryPhotoId);
			parameters.Add("description", description);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photoset;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Deletes the specified photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to delete.</param>
		/// <returns>Returns true when the photoset has been deleted.</returns>
		public bool PhotosetsDelete(string photosetId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.delete");
			parameters.Add("photoset_id", photosetId);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Updates the title and description for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to update.</param>
		/// <param name="title">The new title for the photoset.</param>
		/// <param name="description">The new description for the photoset.</param>
		/// <returns>Returns true when the photoset has been updated.</returns>
		public bool PhotosetsEditMeta(string photosetId, string title, string description)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.editMeta");
			parameters.Add("photoset_id", photosetId);
			parameters.Add("title", title);
			parameters.Add("description", description);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Sets the photos for a photoset.
		/// </summary>
		/// <remarks>
		/// Will remove any previous photos from the photoset. 
		/// The order in thich the photoids are given is the order they will appear in the 
		/// photoset page.
		/// </remarks>
		/// <param name="photosetId">The ID of the photoset to update.</param>
		/// <param name="primaryPhotoId">The ID of the new primary photo for the photoset.</param>
		/// <param name="photoIds">An array of photo IDs.</param>
		/// <returns>Returns true when the photoset has been updated.</returns>
		public bool PhotosetsEditPhotos(string photosetId, string primaryPhotoId, string[] photoIds)
		{
			return PhotosetsEditPhotos(photosetId, primaryPhotoId, string.Join(",", photoIds));
		}


		/// <summary>
		/// Sets the photos for a photoset.
		/// </summary>
		/// <remarks>
		/// Will remove any previous photos from the photoset. 
		/// The order in thich the photoids are given is the order they will appear in the 
		/// photoset page.
		/// </remarks>
		/// <param name="photosetId">The ID of the photoset to update.</param>
		/// <param name="primaryPhotoId">The ID of the new primary photo for the photoset.</param>
		/// <param name="photoIds">An comma seperated list of photo IDs.</param>
		/// <returns>Returns true when the photoset has been updated.</returns>
		public bool PhotosetsEditPhotos(string photosetId, string primaryPhotoId, string photoIds)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.editPhotos");
			parameters.Add("photoset_id", photosetId);
			parameters.Add("primary_photo_id", primaryPhotoId);
			parameters.Add("photo_ids", photoIds);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Gets the context of the specified photo within the photoset.
		/// </summary>
		/// <param name="photoId">The photo id of the photo in the set.</param>
		/// <param name="photosetId">The id of the set.</param>
		/// <returns><see cref="Context"/> of the specified photo.</returns>
		public Context PhotosetsGetContext(string photoId, string photosetId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.getContext");
			parameters.Add("photo_id", photoId);
			parameters.Add("photoset_id", photosetId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				Context c = new Context();
				c.Count = response.ContextCount.Count;
				c.NextPhoto = response.ContextNextPhoto;
				c.PreviousPhoto = response.ContextPrevPhoto;

				return c;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the information about a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return information for.</param>
		/// <returns>A <see cref="Photoset"/> instance.</returns>
		public Photoset PhotosetsGetInfo(string photosetId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.getInfo");
			parameters.Add("photoset_id", photosetId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photoset;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}

		}

		/// <summary>
		/// Gets a list of the currently authenticated users photosets.
		/// </summary>
		/// <returns>A <see cref="Photosets"/> instance containing a collection of photosets.</returns>
		public Photosets PhotosetsGetList()
		{
			return PhotosetsGetList(null);
		}

		/// <summary>
		/// Gets a list of the specified users photosets.
		/// </summary>
		/// <param name="userId">The ID of the user to return the photosets of.</param>
		/// <returns>A <see cref="Photosets"/> instance containing a collection of photosets.</returns>
		public Photosets PhotosetsGetList(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.getList");
			if( userId != null ) parameters.Add("user_id", userId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Photosets;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <returns>A <see cref="Photoset"/> object containing the list of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId)
		{
			return PhotosetsGetPhotos(photosetId, PhotoSearchExtras.All, PrivacyFilter.None, 0, 0);
		}

		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <param name="page">The page to return, defaults to 1.</param>
		/// <param name="perPage">The number of photos to return per page.</param>
		/// <returns>A <see cref="Photoset"/> object containing the list of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId, int page, int perPage)
		{
			return PhotosetsGetPhotos(photosetId, PhotoSearchExtras.All, PrivacyFilter.None, page, perPage);
		}

		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <param name="privacyFilter">The privacy filter to search on.</param>
		/// <returns>A <see cref="Photoset"/> object containing the list of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId, PrivacyFilter privacyFilter)
		{
			return PhotosetsGetPhotos(photosetId, PhotoSearchExtras.All, privacyFilter, 0, 0);
		}

		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <param name="privacyFilter">The privacy filter to search on.</param>
		/// <param name="page">The page to return, defaults to 1.</param>
		/// <param name="perPage">The number of photos to return per page.</param>
		/// <returns>A <see cref="Photoset"/> object containing the list of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId, PrivacyFilter privacyFilter, int page, int perPage)
		{
			return PhotosetsGetPhotos(photosetId, PhotoSearchExtras.All, privacyFilter, page, perPage);
		}

		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <param name="extras">The extras to return for each photo.</param>
		/// <returns>A <see cref="Photoset"/> object containing the list of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId, PhotoSearchExtras extras)
		{
			return PhotosetsGetPhotos(photosetId, extras, PrivacyFilter.None, 0, 0);
		}

		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <param name="extras">The extras to return for each photo.</param>
		/// <param name="page">The page to return, defaults to 1.</param>
		/// <param name="perPage">The number of photos to return per page.</param>
		/// <returns>A <see cref="Photoset"/> object containing the list of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId, PhotoSearchExtras extras, int page, int perPage)
		{
			return PhotosetsGetPhotos(photosetId, extras, PrivacyFilter.None, page, perPage);
		}

		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <param name="extras">The extras to return for each photo.</param>
		/// <param name="privacyFilter">The privacy filter to search on.</param>
		/// <returns>A <see cref="Photoset"/> object containing the list of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId, PhotoSearchExtras extras, PrivacyFilter privacyFilter)
		{
			return PhotosetsGetPhotos(photosetId, extras, privacyFilter, 0, 0);
		}
		
		/// <summary>
		/// Gets a collection of photos for a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to return photos for.</param>
		/// <param name="extras">The extras to return for each photo.</param>
		/// <param name="privacyFilter">The privacy filter to search on.</param>
		/// <param name="page">The page to return, defaults to 1.</param>
		/// <param name="perPage">The number of photos to return per page.</param>
		/// <returns>An array of <see cref="Photo"/> instances.</returns>
		public Photoset PhotosetsGetPhotos(string photosetId, PhotoSearchExtras extras, PrivacyFilter privacyFilter, int page, int perPage)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.getPhotos");
			parameters.Add("photoset_id", photosetId);
			if( extras != PhotoSearchExtras.None ) parameters.Add("extras", Utils.ExtrasToString(extras));
			if( privacyFilter != PrivacyFilter.None ) parameters.Add("privacy_filter", privacyFilter.ToString("d"));
			if( page > 0 ) parameters.Add("page", page);
			if( perPage > 0 ) parameters.Add("per_page", perPage);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				if( response.Photoset.OwnerId != null && response.Photoset.OwnerId.Length > 0 )
				{
					foreach(Photo p in response.Photoset.PhotoCollection)
					{
						p.UserId = response.Photoset.OwnerId;
					}
				}
				return response.Photoset;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Changes the order of your photosets.
		/// </summary>
		/// <param name="photosetIds">An array of photoset IDs, 
		/// ordered with the set to show first, first in the list. 
		/// Any set IDs not given in the list will be set to appear at the end of the list, ordered by their IDs.</param>
		public void PhotosetsOrderSets(string[] photosetIds)
		{
			PhotosetsOrderSets(string.Join(",", photosetIds));
		}

		/// <summary>
		/// Changes the order of your photosets.
		/// </summary>
		/// <param name="photosetIds">A comma delimited list of photoset IDs, 
		/// ordered with the set to show first, first in the list. 
		/// Any set IDs not given in the list will be set to appear at the end of the list, ordered by their IDs.</param>
		public void PhotosetsOrderSets(string photosetIds)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.orderSets");
			parameters.Add("photosetIds", photosetIds);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Removes a photo from a photoset.
		/// </summary>
		/// <remarks>
		/// An exception will be raised if the photo is not in the set.
		/// </remarks>
		/// <param name="photosetId">The ID of the photoset to remove the photo from.</param>
		/// <param name="photoId">The ID of the photo to remove.</param>
		public void PhotosetsRemovePhoto(string photosetId, string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.removePhoto");
			parameters.Add("photoset_id", photosetId);
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Photoset Comments ]
		/// <summary>
		/// Gets a list of comments for a photoset.
		/// </summary>
		/// <param name="photosetId">The id of the photoset to return the comments for.</param>
		/// <returns>An array of <see cref="Comment"/> objects.</returns>
		public Comment[] PhotosetsCommentsGetList(string photosetId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.comments.getList");
			parameters.Add("photoset_id", photosetId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return PhotoComments.GetComments(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Adds a new comment to a photoset.
		/// </summary>
		/// <param name="photosetId">The ID of the photoset to add the comment to.</param>
		/// <param name="commentText">The text of the comment. Can contain some HTML.</param>
		/// <returns>The new ID of the created comment.</returns>
		public string PhotosetsCommentsAddComment(string photosetId, string commentText)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.comments.addComment");
			parameters.Add("photoset_id", photosetId);
			parameters.Add("comment_text", commentText);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				XmlNode node = response.AllElements[0];
				if( node.Attributes.GetNamedItem("id") != null )
					return node.Attributes.GetNamedItem("id").Value;
				else
					throw new ResponseXmlException("Comment ID not found in response.");
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Deletes a comment from a photoset.
		/// </summary>
		/// <param name="commentId">The ID of the comment to delete.</param>
		public void PhotosetsCommentsDeleteComment(string commentId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.comments.deleteComment");
			parameters.Add("comment_id", commentId);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Edits a comment.
		/// </summary>
		/// <param name="commentId">The ID of the comment to edit.</param>
		/// <param name="commentText">The new text for the comment.</param>
		public void PhotosetsCommentsEditComment(string commentId, string commentText)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photosets.comments.editComment");
			parameters.Add("comment_id", commentId);
			parameters.Add("comment_text", commentText);

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Prefs ]
		/// <summary>
		/// Gets the currently authenticated users default safety level.
		/// </summary>
		/// <returns></returns>
		public SafetyLevel PrefsGetSafetyLevel()
		{
			CheckRequiresAuthentication();

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.prefs.getSafetyLevel");

			Response res = GetResponseCache(parameters);
			if( res.Status == ResponseStatus.OK )
			{
				string s = res.AllElements[0].GetAttribute("safety_level");
				return (SafetyLevel)int.Parse(s);
			}
			else
			{
				throw new FlickrApiException(res.Error);
			}
		}

		/// <summary>
		/// Gets the currently authenticated users default hidden from search setting.
		/// </summary>
		/// <returns></returns>
		public HiddenFromSearch PrefsGetHidden()
		{
			CheckRequiresAuthentication();

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.prefs.getHidden");

			Response res = GetResponseCache(parameters);
			if( res.Status == ResponseStatus.OK )
			{
				string s = res.AllElements[0].GetAttribute("hidden");
				return (HiddenFromSearch)int.Parse(s);
			}
			else
			{
				throw new FlickrApiException(res.Error);
			}
		}
		
		/// <summary>
		/// Gets the currently authenticated users default content type.
		/// </summary>
		/// <returns></returns>
		public ContentType PrefsGetContentType()
		{
			CheckRequiresAuthentication();

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.prefs.getContentType");

			Response res = GetResponseCache(parameters);
			if( res.Status == ResponseStatus.OK )
			{
				string s = res.AllElements[0].GetAttribute("content_type");
				return (ContentType)int.Parse(s);
			}
			else
			{
				throw new FlickrApiException(res.Error);
			}
		}
		#endregion

		#region [ Tags ]
		/// <summary>
		/// Get the tag list for a given photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to return tags for.</param>
		/// <returns>An instance of the <see cref="PhotoInfo"/> class containing only the <see cref="PhotoInfo.Tags"/> property.</returns>
		public PhotoInfoTag[] TagsGetListPhoto(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.tags.getListPhoto");
			parameters.Add("api_key", _apiKey);
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.PhotoInfo.Tags.TagCollection;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get the tag list for a given user (or the currently logged in user).
		/// </summary>
		/// <returns>An array of <see cref="Tag"/> objects.</returns>
		public Tag[] TagsGetListUser()
		{
			return TagsGetListUser(null);
		}

		/// <summary>
		/// Get the tag list for a given user (or the currently logged in user).
		/// </summary>
		/// <param name="userId">The NSID of the user to fetch the tag list for. If this argument is not specified, the currently logged in user (if any) is assumed.</param>
		/// <returns>An array of <see cref="Tag"/> objects.</returns>
		public Tag[] TagsGetListUser(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.tags.getListUser");
			if( userId != null && userId.Length > 0 ) parameters.Add("user_id", userId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				XmlNodeList nodes = response.AllElements[0].SelectNodes("//tag");
				Tag[] tags = new Tag[nodes.Count];
				for(int i = 0; i < tags.Length; i++)
				{
					tags[i] = new Tag(nodes[i]);
				}
				return tags;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get the popular tags for a given user (or the currently logged in user).
		/// </summary>
		/// <returns>An array of <see cref="Tag"/> objects.</returns>
		public Tag[] TagsGetListUserPopular()
		{
			return TagsGetListUserPopular(null, 0);
		}
			
		/// <summary>
		/// Get the popular tags for a given user (or the currently logged in user).
		/// </summary>
		/// <param name="count">Number of popular tags to return. defaults to 10 when this argument is not present.</param>
		/// <returns>An array of <see cref="Tag"/> objects.</returns>
		public Tag[] TagsGetListUserPopular(int count)
		{
			return TagsGetListUserPopular(null, count);
		}
			
		/// <summary>
		/// Get the popular tags for a given user (or the currently logged in user).
		/// </summary>
		/// <param name="userId">The NSID of the user to fetch the tag list for. If this argument is not specified, the currently logged in user (if any) is assumed.</param>
		/// <returns>An array of <see cref="Tag"/> objects.</returns>
		public Tag[] TagsGetListUserPopular(string userId)
		{
			return TagsGetListUserPopular(userId, 0);
		}
			
		/// <summary>
		/// Get the popular tags for a given user (or the currently logged in user).
		/// </summary>
		/// <param name="userId">The NSID of the user to fetch the tag list for. If this argument is not specified, the currently logged in user (if any) is assumed.</param>
		/// <param name="count">Number of popular tags to return. defaults to 10 when this argument is not present.</param>
		/// <returns>An array of <see cref="Tag"/> objects.</returns>
		public Tag[] TagsGetListUserPopular(string userId, long count)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.tags.getListUserPopular");
			if( userId != null ) parameters.Add("user_id", userId);
			if( count > 0 ) parameters.Add("count", count.ToString());

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				XmlNodeList nodes = response.AllElements[0].SelectNodes("//tag");
				Tag[] tags = new Tag[nodes.Count];
				for(int i = 0; i < tags.Length; i++)
				{
					tags[i] = new Tag(nodes[i]);
				}
				return tags;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of 'cleaned' tags and the raw values for those tags.
		/// </summary>
		/// <returns>An array of <see cref="RawTag"/> objects.</returns>
		public RawTag[] TagsGetListUserRaw()
		{
			return TagsGetListUserRaw(null);
		}

		/// <summary>
		/// Gets a list of 'cleaned' tags and the raw values for a specific tag.
		/// </summary>
		/// <param name="tag">The tag to return the raw version of.</param>
		/// <returns>An array of <see cref="RawTag"/> objects.</returns>
		public RawTag[] TagsGetListUserRaw(string tag)
		{
			CheckRequiresAuthentication();

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.tags.getListUserRaw");
			if( tag != null && tag.Length > 0 ) parameters.Add("tag", tag);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				XmlNodeList nodes = response.AllElements[0].SelectNodes("//tag");
				RawTag[] tags = new RawTag[nodes.Count];
				for(int i = 0; i < tags.Length; i++)
				{
					tags[i] = new RawTag(nodes[i]);
				}
				return tags;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a list of tags 'related' to the given tag, based on clustered usage analysis.
		/// </summary>
		/// <param name="tag">The tag to fetch related tags for.</param>
		/// <returns>An array of <see cref="Tag"/> objects.</returns>
		public Tag[] TagsGetRelated(string tag)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.tags.getRelated");
			parameters.Add("api_key", _apiKey);
			parameters.Add("tag", tag);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				XmlNodeList nodes = response.AllElements[0].SelectNodes("//tag");
				Tag[] tags = new Tag[nodes.Count];
				for(int i = 0; i < tags.Length; i++)
				{
					tags[i] = new Tag(nodes[i]);
				}
				return tags;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		#endregion

		#region [ Transform ]

		/// <summary>
		/// Rotates a photo on Flickr.
		/// </summary>
		/// <remarks>
		/// Does not rotate the original photo.
		/// </remarks>
		/// <param name="photoId">The ID of the photo.</param>
		/// <param name="degrees">The number of degrees to rotate by. Valid values are 90, 180 and 270.</param>
		public void TransformRotate(string photoId, int degrees)
		{
			if( photoId == null ) 
				throw new ArgumentNullException("photoId");
			if( degrees != 90 && degrees != 180 && degrees != 270 )
				throw new ArgumentException("Must be 90, 180 or 270", "degrees");

			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.transform.rotate");
			parameters.Add("photo_id", photoId);
			parameters.Add("degrees", degrees.ToString("0"));

			FlickrNet.Response response = GetResponseNoCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		#endregion

		#region	[ Geo ]
		/// <summary>
		/// Returns the location data for a give photo.
		/// </summary>
		/// <param name="photoId">The ID of the photo to return the location information for.</param>
		/// <returns>Returns null if the photo has no location information, otherwise returns the location information.</returns>
		public PhotoLocation PhotosGeoGetLocation(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.geo.getLocation");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				return response.PhotoInfo.Location;
			}
			else
			{
				if( response.Error.Code == 2 )
					return null;
				else
					throw new FlickrApiException(response.Error);
			}
		}
		/// <summary>
		/// Sets the geo location for a photo.
		/// </summary>
		/// <param name="photoId">The ID of the photo to set to location for.</param>
		/// <param name="latitude">The latitude of the geo location. A double number ranging from -180.00 to 180.00. Digits beyond 6 decimal places will be truncated.</param>
		/// <param name="longitude">The longitude of the geo location. A double number ranging from -180.00 to 180.00. Digits beyond 6 decimal places will be truncated.</param>
		public void PhotosGeoSetLocation(string photoId, double latitude, double longitude)
		{
			PhotosGeoSetLocation(photoId, latitude, longitude, GeoAccuracy.None);
		}

		/// <summary>
		/// Sets the geo location for a photo.
		/// </summary>
		/// <param name="photoId">The ID of the photo to set to location for.</param>
		/// <param name="latitude">The latitude of the geo location. A double number ranging from -180.00 to 180.00. Digits beyond 6 decimal places will be truncated.</param>
		/// <param name="longitude">The longitude of the geo location. A double number ranging from -180.00 to 180.00. Digits beyond 6 decimal places will be truncated.</param>
		/// <param name="accuracy">The accuracy of the photos geo location.</param>
		public void PhotosGeoSetLocation(string photoId, double latitude, double longitude, GeoAccuracy accuracy)
		{
			System.Globalization.NumberFormatInfo nfi = System.Globalization.NumberFormatInfo.InvariantInfo;
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.geo.setLocation");
			parameters.Add("photo_id", photoId);
			parameters.Add("lat", latitude.ToString(nfi));
			parameters.Add("lon", longitude.ToString(nfi));
			if( accuracy != GeoAccuracy.None )
				parameters.Add("accuracy", ((int)accuracy).ToString());

			FlickrNet.Response response = GetResponseNoCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Removes Location information.
		/// </summary>
		/// <param name="photoId">The photo ID of the photo to remove information from.</param>
		/// <returns>Returns true if the location information as found and removed. Returns false if no photo information was found.</returns>
		public bool PhotosGeoRemoveLocation(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.geo.removeLocation");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseNoCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				return true;
			}
			else
			{
				if( response.Error.Code == 2 )
					return false;
				else
					throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of photos that do not contain geo location information.
		/// </summary>
		/// <returns>A list of photos that do not contain location information.</returns>
		public Photos PhotosGetWithoutGeoData()
		{
			PartialSearchOptions options = new PartialSearchOptions();
			return PhotosGetWithoutGeoData(options);
		}

		/// <summary>
		/// Gets a list of photos that do not contain geo location information.
		/// </summary>
		/// <param name="options">A limited set of options are supported.</param>
		/// <returns>A list of photos that do not contain location information.</returns>
		public Photos PhotosGetWithoutGeoData(PartialSearchOptions options)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getWithoutGeoData");
			Utils.PartialOptionsIntoArray(options, parameters);

			FlickrNet.Response response = GetResponseCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets a list of photos that do not contain geo location information.
		/// </summary>
		/// <param name="options">A limited set of options are supported. 
		/// Unsupported arguments are ignored. 
		/// See http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html for supported properties.</param>
		/// <returns>A list of photos that do not contain location information.</returns>
		[Obsolete("Use the PartialSearchOptions instead")]
		public Photos PhotosGetWithoutGeoData(PhotoSearchOptions options)
		{
			PartialSearchOptions newOptions = new PartialSearchOptions(options);
			return PhotosGetWithoutGeoData(newOptions);
		}

		/// <summary>
		/// Gets a list of photos that contain geo location information.
		/// </summary>
		/// <remarks>
		/// Note, this method doesn't actually return the location information with the photos, 
		/// unless you specify the <see cref="PhotoSearchExtras.Geo"/> option in the <c>extras</c> parameter.
		/// </remarks>
		/// <returns>A list of photos that contain Location information.</returns>
		public Photos PhotosGetWithGeoData()
		{
			PartialSearchOptions options = new PartialSearchOptions();
			return PhotosGetWithGeoData(options);
		}

		/// <summary>
		/// Gets a list of photos that contain geo location information.
		/// </summary>
		/// <remarks>
		/// Note, this method doesn't actually return the location information with the photos, 
		/// unless you specify the <see cref="PhotoSearchExtras.Geo"/> option in the <c>extras</c> parameter.
		/// </remarks>
		/// <param name="options">A limited set of options are supported. 
		/// Unsupported arguments are ignored. 
		/// See http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html for supported properties.</param>
		/// <returns>A list of photos that contain Location information.</returns>
		[Obsolete("Use the new PartialSearchOptions instead")]
		public Photos PhotosGetWithGeoData(PhotoSearchOptions options)
		{
			PartialSearchOptions newOptions = new PartialSearchOptions(options);
			return PhotosGetWithGeoData(newOptions);
		}
		
		/// <summary>
		/// Gets a list of photos that contain geo location information.
		/// </summary>
		/// <remarks>
		/// Note, this method doesn't actually return the location information with the photos, 
		/// unless you specify the <see cref="PhotoSearchExtras.Geo"/> option in the <c>extras</c> parameter.
		/// </remarks>
		/// <param name="options">The options to filter/sort the results by.</param>
		/// <returns>A list of photos that contain Location information.</returns>
		public Photos PhotosGetWithGeoData(PartialSearchOptions options)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.getWithGeoData");
			Utils.PartialOptionsIntoArray(options, parameters);

			FlickrNet.Response response = GetResponseCache(parameters);
			if( response.Status == ResponseStatus.OK )
			{
				return response.Photos;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Get permissions for a photo.
		/// </summary>
		/// <param name="photoId">The id of the photo to get permissions for.</param>
		/// <returns>An instance of the <see cref="PhotoPermissions"/> class containing the permissions of the specified photo.</returns>
		public GeoPermissions PhotosGeoGetPerms(string photoId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.geo.getPerms");
			parameters.Add("photo_id", photoId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new GeoPermissions(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Set the permission for who can see geotagged photos on Flickr.
		/// </summary>
		/// <param name="photoId">The ID of the photo permissions to update.</param>
		/// <param name="IsPublic"></param>
		/// <param name="IsContact"></param>
		/// <param name="IsFamily"></param>
		/// <param name="IsFriend"></param>
		public void PhotosGeoSetPerms(string photoId, bool IsPublic, bool IsContact, bool IsFamily, bool IsFriend)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.photos.geo.setPerms");
			parameters.Add("photo_id", photoId);
			parameters.Add("is_public", IsPublic?"1":"0");
			parameters.Add("is_contact", IsContact?"1":"0");
			parameters.Add("is_friend", IsFriend?"1":"0");
			parameters.Add("is_family", IsFamily?"1":"0");

			FlickrNet.Response response = GetResponseNoCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}


		#endregion

		#region [ Tests ]
		/// <summary>
		/// Can be used to call unsupported methods in the Flickr API.
		/// </summary>
		/// <remarks>
		/// Use of this method is not supported. 
		/// The way the FlickrNet API Library works may mean that some methods do not return an expected result 
		/// when using this method.
		/// </remarks>
		/// <param name="method">The method name, e.g. "flickr.test.null".</param>
		/// <param name="parameters">A list of parameters. Note, api_key is added by default and is not included. Can be null.</param>
		/// <returns>An array of <see cref="XmlElement"/> instances which is the expected response.</returns>
		public XmlElement[] TestGeneric(string method, NameValueCollection parameters)
		{
			Hashtable _parameters = new Hashtable();
			if( parameters != null )
			{
				foreach(string key in parameters.AllKeys)
				{
					_parameters.Add(key, parameters[key]);
				}
			}
			_parameters.Add("method", method);

			FlickrNet.Response response = GetResponseNoCache(_parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.AllElements;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		/// <summary>
		/// Runs the flickr.test.echo method and returned an array of <see cref="XmlElement"/> items.
		/// </summary>
		/// <param name="echoParameter">The parameter to pass to the method.</param>
		/// <param name="echoValue">The value to pass to the method with the parameter.</param>
		/// <returns>An array of <see cref="XmlElement"/> items.</returns>
		/// <remarks>
		/// The APi Key has been removed from the returned array and will not be shown.
		/// </remarks>
		/// <example>
		/// <code>
		/// XmlElement[] elements = flickr.TestEcho("&amp;param=value");
		/// foreach(XmlElement element in elements)
		/// {
		///		if( element.Name = "method" )
		///			Console.WriteLine("Method = " + element.InnerXml);
		///		if( element.Name = "param" )
		///			Console.WriteLine("Param = " + element.InnerXml);
		/// }
		/// </code>
		/// </example>
		public XmlElement[] TestEcho(string echoParameter, string echoValue)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.test.echo");
			parameters.Add("api_key", _apiKey);
			if( echoParameter != null && echoParameter.Length > 0 )
			{
				parameters.Add(echoParameter, echoValue);
			}

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				// Remove the api_key element from the array.
				XmlElement[] elements = new XmlElement[response.AllElements.Length - 1];
				int c = 0;
				foreach(XmlElement element in response.AllElements)
				{
					if(element.Name != "api_key" )
						elements[c++] = element;
				}
				return elements;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Test the logged in state of the current Filckr object.
		/// </summary>
		/// <returns>The <see cref="FoundUser"/> object containing the username and userid of the current user.</returns>
		public FoundUser TestLogin()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.test.login");

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new FoundUser(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Urls ]
		/// <summary>
		/// Returns the url to a group's page.
		/// </summary>
		/// <param name="groupId">The NSID of the group to fetch the url for.</param>
		/// <returns>An instance of the <see cref="Uri"/> class containing the URL of the group page.</returns>
		public Uri UrlsGetGroup(string groupId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.urls.getGroup");
			parameters.Add("api_key", _apiKey);
			parameters.Add("group_id", groupId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				if( response.AllElements[0] != null && response.AllElements[0].Attributes["url"] != null )
					return new Uri(response.AllElements[0].Attributes["url"].Value);
				else
					return null;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns the url to a user's photos.
		/// </summary>
		/// <returns>An instance of the <see cref="Uri"/> class containing the URL for the users photos.</returns>
		public Uri UrlsGetUserPhotos()
		{
			return UrlsGetUserPhotos(null);
		}
		
		/// <summary>
		/// Returns the url to a user's photos.
		/// </summary>
		/// <param name="userId">The NSID of the user to fetch the url for. If omitted, the calling user is assumed.</param>
		/// <returns>The URL of the users photos.</returns>
		public Uri UrlsGetUserPhotos(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.urls.getUserPhotos");
			if( userId != null && userId.Length > 0 ) parameters.Add("user_id", userId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				if( response.AllElements[0] != null && response.AllElements[0].Attributes["url"] != null )
					return new Uri(response.AllElements[0].Attributes["url"].Value);
				else
					return null;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns the url to a user's profile.
		/// </summary>
		/// <returns>An instance of the <see cref="Uri"/> class containing the URL for the users profile.</returns>
		public Uri UrlsGetUserProfile()
		{
			return UrlsGetUserProfile(null);
		}

		/// <summary>
		/// Returns the url to a user's profile.
		/// </summary>
		/// <param name="userId">The NSID of the user to fetch the url for. If omitted, the calling user is assumed.</param>
		/// <returns>An instance of the <see cref="Uri"/> class containing the URL for the users profile.</returns>
		public Uri UrlsGetUserProfile(string userId)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.urls.getUserProfile");
			if( userId != null && userId.Length > 0 ) parameters.Add("user_id", userId);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				if( response.AllElements[0] != null && response.AllElements[0].Attributes["url"] != null )
					return new Uri(response.AllElements[0].Attributes["url"].Value);
				else
					return null;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a group NSID, given the url to a group's page or photo pool.
		/// </summary>
		/// <param name="urlToFind">The url to the group's page or photo pool.</param>
		/// <returns>The ID of the group at the specified URL on success, a null reference (Nothing in Visual Basic) if the group cannot be found.</returns>
		public string UrlsLookupGroup(string urlToFind)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.urls.lookupGroup");
			parameters.Add("api_key", _apiKey);
			parameters.Add("url", urlToFind);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				if( response.AllElements[0] != null && response.AllElements[0].Attributes["id"] != null )
				{
					return response.AllElements[0].Attributes["id"].Value;
				}
				else
				{
					return null;
				}
			}
			else
			{
				if( response.Error.Code == 1 )
					return null;
				else
					throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Returns a user NSID, given the url to a user's photos or profile.
		/// </summary>
		/// <param name="urlToFind">Thr url to the user's profile or photos page.</param>
		/// <returns>An instance of the <see cref="FoundUser"/> class containing the users ID and username.</returns>
		public FoundUser UrlsLookupUser(string urlToFind)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.urls.lookupUser");
			parameters.Add("api_key", _apiKey);
			parameters.Add("url", urlToFind);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return new FoundUser(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}
		#endregion

		#region [ Reflection ]
		/// <summary>
		/// Gets an array of supported method names for Flickr.
		/// </summary>
		/// <remarks>
		/// Note: Not all methods might be supported by the FlickrNet Library.</remarks>
		/// <returns></returns>
		public string[] ReflectionGetMethods()
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.reflection.getMethods");
			parameters.Add("api_key", _apiKey);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return Methods.GetMethods(response.AllElements[0]);
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		/// <summary>
		/// Gets the method details for a given method.
		/// </summary>
		/// <param name="methodName">The name of the method to retrieve.</param>
		/// <returns>Returns a <see cref="Method"/> instance for the given method name.</returns>
		public Method ReflectionGetMethodInfo(string methodName)
		{
			Hashtable parameters = new Hashtable();
			parameters.Add("method", "flickr.reflection.getMethodInfo");
			parameters.Add("api_key", _apiKey);
			parameters.Add("method_name", methodName);

			FlickrNet.Response response = GetResponseCache(parameters);

			if( response.Status == ResponseStatus.OK )
			{
				return response.Method;
			}
			else
			{
				throw new FlickrApiException(response.Error);
			}
		}

		#endregion

		#region [ MD5 Hash ]
		private static string Md5Hash(string unhashed)
		{
			System.Security.Cryptography.MD5CryptoServiceProvider csp = new System.Security.Cryptography.MD5CryptoServiceProvider();
			byte[] bytes = System.Text.Encoding.UTF8.GetBytes(unhashed);
			byte[] hashedBytes = csp.ComputeHash(bytes, 0, bytes.Length);
			return BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
		}
		#endregion
	}

}