This file is indexed.

/usr/share/perl5/WWW/Facebook/API.pm is in libwww-facebook-api-perl 0.4.18-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
#########################################################################
# ex: set ts=8 sw=4 et
#########################################################################
package WWW::Facebook::API;

use warnings;
use strict;
use Carp;

use version; our $VERSION = qv('0.4.18');

use LWP::UserAgent;
use Time::HiRes qw(time);
use Digest::MD5 qw(md5_hex);
use Encode qw(encode_utf8 is_utf8);
use CGI;
use CGI::Util qw(escape);

use WWW::Facebook::API::Exception;

our @namespaces = qw(
    Admin           Application     Auth
    Canvas          Comments        Connect
    Data            Events          FBML
    Feed            FQL             Friends
    Groups          Intl            Links
    LiveMessage     Message         Notes
    Notifications   Pages           Permissions
    Photos          Profile         SMS
    Status          Stream          Users
    Video
);

for (@namespaces) {
    my $package = __PACKAGE__ . "::$_";
    my $name    = "\L$_";
    ## no critic
    my $namespace = eval qq(
        use $package;

        sub $name {
            my \$self = shift;
            unless ( \$self->{'_$name'} ) {
                \$self->{'_$name'} = $package->new( base => \$self );
            }
            return \$self->{'_$name'};
        }

        package $package;
        sub base { return shift->{'base'}; };
        sub new {
            my ( \$class, \%args ) = \@_;
            my \$self = bless \\\%args, \$class;

            delete \$self->{\$_} for grep { !/base/xms } keys %{\$self};
            \$self->\$_ for keys %{\$self};

            return \$self;
        };
        1;

    );
    croak "Cannot create namespace $name: $@\n" if not $namespace;
}

our %attributes = (
    parse        => 1,
    format       => 'JSON',
    debug        => 0,
    throw_errors => 1,
    api_version  => '1.0',
    apps_uri     => 'http://apps.facebook.com/',
    server_uri   => 'http://api.facebook.com/restserver.php',
    (   map { $_ => q{} }
            qw(
            api_key             secret      desktop
            last_call_success   last_error  skipcookie
            popup               next        session_key
            session_expires     session_uid callback
            app_path            ua          query
            config              app_id      call_as_apikey
            )
    ),
);

for ( keys %attributes ) {
    ## no critic
    my $attribute = eval qq( 
        sub $_ {
            my \$self = shift;
            return \$self->{$_} = shift if defined \$_[0];
            return \$self->{$_} if defined \$self->{$_};
            return \$self->{$_} = '$attributes{$_}';
        }
        1;
    );
    croak "Cannot create attribute $_: $@\n" if not $attribute;
}

sub _set_from_outside {
    my $self = shift;

    my $app_path = '_' . ( $self->{'app_path'} || $self->app_path );
    $app_path =~ tr/a-z/A-Z/;
    $app_path =~ tr/A-Za-z0-9_/_/c;

    my %ENV_VARS = qw(
        WFA_API_KEY     api_key
        WFA_SECRET      secret
        WFA_DESKTOP     desktop
        WFA_SESSION_KEY session_key
    );

    $self->_set_from_file( $app_path, %ENV_VARS ) if $self->{'config'};
    $self->_set_from_env( $app_path, %ENV_VARS );

    return;
}

sub _set_from_file {
    my $self     = shift;
    my $app_path = shift;
    my %ENV_VARS = @_;

    open my $config, '<', $self->{'config'}    ## no critic
        or croak "Cannot open $self->{'config'}";

    while (<$config>) {
        carp "Config line: $_" if $self->{'debug'};
        chomp;
        my ( $key, $val ) = split m/=/xms, $_, 2;
        next if !$key;
        carp "Key/Val pair: $key -> $val" if $self->{'debug'};
        for ( $key, $val ) {
            s/\A\s+//xms;
            s/\s+\Z//xms;
        }
        $ENV{$key} ||= $val;
    }

    close $config or croak "Cannot close $self->{'config'}";

    return;
}

sub _set_from_env {
    my $self     = shift;
    my $app_path = shift;
    my %ENV_VARS = @_;

    for ( keys %ENV_VARS ) {
        if ( exists $ENV{ $_ . $app_path } ) {
            $self->{ $ENV_VARS{$_} } ||= $ENV{ $_ . $app_path };
        }
        elsif ( exists $ENV{$_} ) {
            $self->{ $ENV_VARS{$_} } ||= $ENV{$_};
        }
    }

    return;
}

sub new {
    my ( $self, %args ) = @_;
    my $class = ref $self || $self;
    $self = bless \%args, $class;
    $self->_set_from_outside();    # set api_key etc. if needed

    $self->{'ua'} ||=
        LWP::UserAgent->new( agent => "Perl-WWW-Facebook-API/$VERSION" );
    my $is_attribute = join q{|}, keys %attributes;
    delete $self->{$_} for grep { !/^ $is_attribute $/xms } keys %{$self};

    # set up default namespaces
    $self->$_($self) for map {"\L$_"} @namespaces;

    # set up default attributes
    $self->$_ for keys %attributes;

    return $self;
}

sub log_string {
    my ( $self, $params, $response ) = @_;
    my $string = "\nparams = \n";

    $string .= "\t$_:$params->{$_}\n" for sort keys %{$params};
    $string .= "response =\n$response\n";

    return $string;
}

sub call_success {
    my $self = shift;
    $self->last_call_success(shift) if @_;
    $self->last_error(shift)        if @_;
    return [ $self->last_call_success, $self->last_error ];
}

sub call {
    my ( $self, $method, %args ) = @_;
    my ( $response, $params, $sig, $raw_data, $filename );
    $self->call_success(1);

    if ( $self->call_as_apikey ) { 
         $args{'call_as_apikey'} = $self->call_as_apikey;
    }

    ( $params, $raw_data, $filename ) =
        $self->_format_and_check_params( $method, %args );
    $sig = $self->generate_sig(
        params => $params,
        secret => delete $params->{'secret'},
    );

    $response = $self->_post_request( $params, $sig, $raw_data, $filename );

    carp $self->log_string( $params, $response ) if $self->debug;
    if ( $self->_has_error_response($response) ) {
        if ( $self->throw_errors ) {
            warn WWW::Facebook::API::Exception->new(
                $method, $params, $response
            );
        }
    }

    return $self->_reformat_response( $params, $response );
}

sub generate_sig {
    my ( $self, %args ) = @_;
    my %params = %{ $args{'params'} };
    return md5_hex( ( map {"$_=$params{$_}"} sort keys %params ),
        $args{'secret'} );
}

sub verify_sig {
    my ( $self, %args ) = @_;
    return $args{'sig'} eq $self->generate_sig(
        params => $args{'params'},
        secret => $args{'secret'} || $self->secret,
    );
}

sub session {
    my ( $self, %args ) = @_;
    $self->{"session_$_"} = $args{$_} for keys %args;
    return;
}

sub redirect {
    my $self = shift;
    my $url  = shift;
    $self->query(shift);

    if ( $self->canvas->in_fb_canvas ) {
        return qq{<fb:redirect url="$url" />};
    }
    elsif ($url =~ m{^https?://([^/]*\.)?facebook\.com(:\d+)?}ixms
        && $self->session_uid )
    {
        return join q{},
            map {"$_\n"}
            '<script type="text/javascript">'
            . qq{top.location.href = "$url"}
            . '</script>';
    }

    print CGI->new->redirect(
        $self->get_app_url( next => $self->get_login_url ) );
    return 1;
}

sub require_add   { return shift->require( 'add',   @_ ); }
sub require_frame { return shift->require( 'frame', @_ ); }
sub require_login { return shift->require( 'login', @_ ); }

sub require {    ## no critic
    my $self = shift;
    my $what = shift;
    $self->query(shift);

    if ( $what eq 'login' ) {
        unshift @_, qw( canvas ) if $self->canvas->in_frame;
    }
    if ( $what eq 'frame' ) {
        return if $self->canvas->in_frame;
        unshift @_, qw( canvas );
        $what = 'login';
    }

    my $user = $self->canvas->get_fb_params->{'user'};
    if ( $what eq 'add' ) {
        if ( !$self->canvas->get_fb_params->{'added'} ) {
            $user = undef;
        }
    }
    return if $user;

    return $self->redirect( $self->get_url( $what, @_ ) );
}

sub get_facebook_url { return shift->get_url( 'facebook', @_ ); }
sub get_add_url      { return shift->get_url( 'add',      @_ ); }
sub get_infinite_session_url { return shift->get_url('infinite_session'); }
sub get_login_url            { return shift->get_url( 'login', @_ ); }
sub get_app_url              { return shift->get_url( 'app', @_ ); }

sub get_url {
    my $self = shift;
    my $type = shift;

    if ( $type eq 'facebook' ) {
        my $site = shift || 'www';
        return "http://$site.facebook.com";
    }

    if ( $type eq 'app' ) {
        return $self->apps_uri . $self->app_path . q{/};
    }

    if ( $type eq 'custom' ) {
        return (shift) . $self->_add_url_params(@_);
    }

    return $self->get_url('facebook')
        . (
          $type eq 'add'              ? '/add.php'
        : $type eq 'infinite_session' ? '/code_gen.php'
        : $type eq 'login'            ? '/login.php'
        : q{}
        ) . $self->_add_url_params(@_);
}

sub unescape_string {
    my $self   = shift;
    my $string = shift;
    $string =~ s/(?<!\\)(\\.)/qq("$1")/xmsgee;
    return $string;
}

sub _add_url_params {
    my $self   = shift;
    my $params = q{?api_key=} . $self->api_key . q{&v=1.0};
    if (@_) {
        if ( @_ % 2 ) {

            # Odd number of elelemts, so didn't pass in canvas => 1
            $params .= q{&canvas} if grep { $_ eq 'canvas' } @_;  ## no critic
            @_ = grep { $_ ne 'canvas' } @_;
        }
        my %params = @_;
        $params .= q{&canvas} if delete $params{'canvas'};

        for ( sort keys %params ) {
            next if not defined $params{$_};
            $params{$_} = escape( $params{$_} ) if $_ eq 'next';
            $params .= "&$_=$params{$_}";
        }
    }
    return $params;
}

sub _parser {
    my $parser = JSON::Any->new;

    $parser->handler->allow_nonref;
    return $parser;
}

sub _parse {
    my ( $self, $response ) = @_;

    # Some shortcuts
    return q{} if $response =~ /\A"?"?\Z/xms;
    return 1   if $response =~ /\A"?true"?\Z/xms;
    return 0   if $response =~ /\A"?false"?\Z/xms;

    my $parser;
    eval { $parser = _parser(); 1; } or do {

        # Only load JSON::Any if we haven't already.  Lets the developers
        # pick their choice of JSON modules (JSON::DWIW, for example)
        ## no critic
        eval q{use JSON::Any};
        croak "Unable to load JSON module for parsing:$@\n" if $@;
        $parser = _parser();
    };
    carp 'JSON::Any is parsing with ' . $parser->handlerType if $self->debug;

    return $parser->decode($response);
}

sub _check_values_of {
    my ( $self, $params ) = @_;

    if ( $self->desktop ) {
        $params->{'call_id'} = time if $self->desktop;
    }

    if ( $params->{'method'} !~ m/^auth/xms ) {
        $params->{'session_key'} ||= $self->session_key;
        if ( !$params->{'callback'} && $self->callback ) {
            $params->{'callback'} = $self->callback;
        }
    }

    $params->{'method'} = "facebook.$params->{'method'}";
    $params->{'v'} ||= $self->api_version;

    $params->{$_} ||= $self->$_ for qw(api_key format);
    return;
}

sub _format_and_check_params {
    my ( $self, $method, %args ) = @_;

    my $params = delete $args{'params'} || {};
    $params->{$_} = $args{$_} for keys %args;
    $params->{'secret'} ||= $self->secret;
    $params->{'method'} ||= $method;

    $self->_check_values_of($params);

    # reformat arrays and add each param to digest
    for ( keys %{$params} ) {
        if ( ref $params->{$_} eq 'ARRAY' ) {
            $params->{$_} = join q{,}, @{ $params->{$_} };
        }

        if ( is_utf8( $params->{$_} ) ) {
            $params->{$_} = encode_utf8( $params->{$_} );
        }
    }

    croak '_format_and_check_params must be called in list context!'
        if !wantarray;

    return ( $params, delete $params->{'data'}, delete $params->{'filename'} );
}

sub _has_error_response {
    my $self     = shift;
    my $response = shift;

    # The different type of error responses
    my $json = q{ \{ "error_code" \D+ (\d+) .* "error_msg" [^"]+ "([^"]+)" };
    my $xml  = q{ <error_code> (\d+) .* <error_msg> ([^<]+)};

    for ( $json, $xml ) {
        if ( $response =~ m/$_/xms ) {
            $self->call_success( 0, "$1: $2" );
            return 1;
        }
    }

    return;
}

sub _reformat_response {
    my ( $self, $params, $response ) = @_;

    # get actual response when web app
    if ( $params->{'callback'} ) {
        $response =~ s/^$params->{'callback'} [^(]* [(](.+) [)];$/$1/xms;
    }
    undef $params;

    # ... and unescape it if it's not going to be parsed
    if ( !$self->desktop && !$self->parse ) {
        $response = $self->unescape_string($response);
    }

    if ( $self->parse && $self->format eq 'XML' ) {
        $self->parse(0);
        carp q{format is XML: setting parse to 0} if $self->debug;
    }
    return $response if !$self->parse;

    $response = $self->_parse($response);
    return if $self->_is_empty_response($response);
    return $response;
}

sub _is_empty_response {
    my ( $self, $response ) = @_;

    return 1 if ref $response eq 'HASH'  && !keys %{$response};
    return 1 if ref $response eq 'ARRAY' && @{$response} == 0;
    return;
}

sub _post_request {
    my ( $self, $params, $sig, $raw_data, $filename ) = @_;

    my $post_params = [ map { $_ => $params->{$_} } sort keys %{$params} ];
    push @{$post_params}, 'sig' => $sig;

    if ($raw_data) {
        push @{$post_params}, data => [
            undef, ( $filename || 'filename'),
            'Content-Type' => 'application/octet-stream',
            'Content'      => $raw_data,
        ];
    }
    return $self->ua->post(
        $self->server_uri,
        'Content_type' => 'form-data',
        'Content'      => $post_params,
    )->content;
}

1;    # Magic true value required at end of module
__END__

=head1 NAME

WWW::Facebook::API - Facebook API implementation

=head1 VERSION

This document and others distributed with this module describe
WWW::Facebook::API version 0.4.18

=head1 SYNOPSIS

    use WWW::Facebook::API;

    # @ENV{qw/WFA_API_KEY WFA_SECRET WFA_DESKTOP/} are the initial values,
    # so use those if you only have one app and don't want to pass in values
    # to constructor
    my $client = WWW::Facebook::API->new(
        desktop => 0,
        api_key => 'your api key',
        secret => 'your secret key',
    );
    
    # Change API key and secret
    print "Enter your public API key: ";
    chomp( my $val = <STDIN> );
    $client->api_key($val);
    print "Enter your API secret: ";
    chomp($val = <STDIN> );
    $client->secret($val);
    
    # not needed if web app (see $client->canvas->get_fb_params)
    $client->auth->get_session( $token );
    
    use Data::Dumper;
    my $friends_perl = $client->friends->get;
    print Dumper $friends_perl;
    
    my $notifications_perl = $client->notifications->get;
    print Dumper $notifications_perl;
    
    # Current user's quotes
    my $quotes_perl = $client->users->get_info(
        uids   => $friends_perl,
        fields => ['quotes']
    );
    print Dumper $quotes_perl;
    
    $client->auth->logout;

=head1 DESCRIPTION

A Perl implementation of the Facebook API, working off of the canonical Java
and PHP implementations. By default it uses L<JSON::Any> to parse the response
returned by Facebook's server. There is an option to return the raw response
in either XML or JSON (See the C<parse> method below). As the synopsis states,
the following environment variables are used to set the defaults for new
instances:

    WFA_API_KEY
    WFA_SECRET
    WFA_SESSION_KEY
    WFA_DESKTOP

Additionally, for each instance that is created, the following environment
variables are used if no values are set:

    WFA_API_KEY_APP_PATH
    WFA_SECRET_APP_PATH
    WFA_SESSION_KEY_APP_PATH
    WFA_DESKTOP_APP_PATH

Where C<APP_PATH> is replaced by whatever $client->app_path returns, with all
non-alphanumeric characters replaced with an underscore and all characters
upcased (e.g., foo-bar-baz becomes FOO_BAR_BAZ).

=head1 SUBROUTINES/METHODS

=over

=item new( %params )

Returns a new instance of this class. You are able to pass in any of the
attribute method names in L<WWW::Facebook::API> to set its value:

    my $client = WWW::Facebook::API->new(
        parse           => 1,
        format          => 'JSON',
        secret          => 'application_secret_key',
        api_key         => 'application_key',
        session_key     => 'session_key',
        session_expires => 'session_expires',
        session_uid     => 'session_uid',
        desktop         => 1,
        api_version     => '1.0',
        callback        => 'callback_url',
        next            => 'next',
        popup           => 'popup',
        skipcookie      => 'skip_cookie',
        throw_errors    => 1,
    );
    $copy = $client->new;

=back

=head1 NAMESPACE METHODS

All method names from the Facebook API are lower_cased instead of CamelCase.

=over

=item admin

admin namespace of the API (See L<WWW::Facebook::API::Admin>).

=item application

application namespace of the API (See L<WWW::Facebook::API::Application>).

=item auth

For desktop apps, these are synonymous:

    $client->auth->get_session( $client->auth->create_token );
    $client->auth->get_session;

And that's all you really have to do (but see L<WWW::Facebook::API::Auth> for
details about opening a browser on *nix for Desktop apps). C<get_session>
automatically sets C<session_uid>, C<session_key>, and C<session_expires> for
C<$client>. It returns nothing.

If the desktop attribute is set to false the C<$token> must be the auth_token
returned from Facebook to your web app for that user:

    if ( $q->param('auth_token')  ) {
        $client->auth->get_session( $q->param('auth_token') );
    }

C<get_session> automatically sets C<session_uid>, C<session_key>, and
C<session_expires> for C<$client>. It returns nothing.

See L<WWW::Facebook::API::Auth> for details.

=item canvas

Work with the canvas. See L<WWW::Facebook::API::Canvas>.

    $response = $client->canvas->get_user( $q )
    $response = $client->canvas->get_fb_params( $q )
    $response = $client->canvas->get_non_fb_params( $q )
    $response = $client->canvas->validate_sig( $q )
    $response = $client->canvas->in_fb_canvas( $q )
    $response = $client->canvas->in_frame( $q )

=item comments

comments namespace of the API (See L<WWW::Facebook::API::Comments>).

=item connect

connect namespace of the API (See L<WWW::Facebook::API::Connect>).

=item data

data namespace of the API (See L<WWW::Facebook::API::Data>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->data->set_cookie( uid => 23, qw/name foo value bar/);
    $cookies = $client->data->get_cookies(
        uid => 4534,
        name => 'foo',
    );

=item events

events namespace of the API (See L<WWW::Facebook::API::Events>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->events->get(
        uid => 'uid',
        eids => [@eids],
        start_time => 'utc',
        end_time => 'utc',
        rsvp_status => 'attending|unsure|declined|not_replied',
    );
    $response = $client->events->get_members( eid => 233 );

=item fbml

fbml namespace of the API (See L<WWW::Facebook::API::FBML>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->fbml->set_ref_handle( handle => '', fbml => '');
    $response = $client->fbml->refresh_img_src( url => '');
    $response = $client->fbml->refresh_ref_url( url => '');

=item feed

feed namespace of the API (See L<WWW::Facebook::API::Feed>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response
        = $client->feed->publish_story_to_user(
            title   => 'title',
            body    => 'markup',
            ...
    );
    $response
        = $client->feed->publish_action_of_user(
            title   => 'title',
            body    => 'markup',
            ...
    );
    $response
        = $client->feed->publish_templatized_action(
            actor_id       => 'title',
            title_template => 'markup',
            ...
    );

=item fql

fql namespace of the API (See L<WWW::Facebook::API::FQL>):

    $response = $client->fql->query( query => 'FQL query' );

=item friends

friends namespace of the API (See L<WWW::Facebook::API::Friends>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->friends->get;
    $response = $client->friends->get_app_users;
    $response
        = $client->friends->are_friends( uids1 => [1,5,8], uids2 => [2,3,4] );
    $response = $client->friends->get_lists;

=item groups

groups namespace of the API (See L<WWW::Facebook::API::Groups>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->groups->get( uid => 234324, gids => [2423,334] );
    $response = $client->groups->get_members( gid => 32 );

=item intl

intl namespace of the API (See L<WWW::Facebook::API::Intl>).

=item links

links namespace of the API (See L<WWW::Facebook::API::Links>).

=item livemesssage

liveMesssage namespace of the API (See L<WWW::Facebook::API::LiveMesssage>).

=item message

message namespace of the API (See L<WWW::Facebook::API::Message>).

=item notes

notes namespace of the API (See L<WWW::Facebook::API::Notes>).

=item notifications

notifications namespace of the API (See L<WWW::Facebook::API::Notifications>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->notifications->get;
    $response = $client->notifications->send(
        to_ids => [ 1, 3 ],
        notification => 'FBML notification markup',
    );
    $response = $client->notifications->send_email(
        recipients => [1, 2343, 445],
        subject => 'subject',
        text => 'text version of email body',
        fbml  => 'fbml version of email body',
    );

=item pages

pages namespace of the API (See L<WWW::Facebook::API::Pages>). All
method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->pages->get_info(
        page_ids => [@pages],
        fields   => [@fields],
        uid      => 'user',
        type     => 'page type',
    );
    $page_added_app = $client->pages->is_app_added( page_id => 'page' );
    $is_admin = $client->pages->is_admin( page_id => 'page' );
    $is_fan = $client->pages->is_fan( page_id => 'page', uid => 'uid' )

=item permissions

permissions namespace of the API (See L<WWW::Facebook::API::Permissions>).

=item photos

photos namespace of the API (See L<WWW::Facebook::API::Photos>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->photos->add_tag(
            pid => 2,
            tag_uid => 3,
            tag_text => "me",
            x => 5,
            y => 6
        );
    $response = $client->photos->create_album(
            name => 'fun in the sun',
            location => 'California',
            description => "Summer '07",
    );
    $response = $client->photos->get( aid => 2, pids => [4,7,8] );
    $response = $client->photos->get_albums( uid => 1, pids => [3,5] );
    $response = $client->photos->get_tags( pids => [4,5] );
    $response = $client->photos->upload(
        aid => 5,
        caption => 'beach',
        data => 'raw data',
    );

=item profile

profile namespace of the API (See L<WWW::Facebook::API::Profile>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->profile->get_fbml( uid => 3 );
    $response = $client->profile->set_fbml( uid => 5,
        profile => 'markup',
        profile_action => 'markup',
        mobile_profile => 'markup',
    );

=item sms

sms namespace of the API (See L<WWW::Facebook::API::SMS>).

=item status

status namespace of the API (See L<WWW::Facebook::API::Status>).

=item stream

stream namespace of the API (See L<WWW::Facebook::API::Stream>).

=item users

users namespace of the API (See L<WWW::Facebook::API::Users>).
All method names from the Facebook API are lower_cased instead of CamelCase:

    $response = $client->users->get_info(
        uids => 2343,
        fields => [ qw/about_me quotes/ ]
    );
    $uid = $client->users->get_logged_in_user;
    $response = $client->users->has_app_permission(
        ext_perm => 'status_update|photo_upload'
    );
    $app_added = $client->users->is_app_user;
    $response = $client->users->set_status(
        status => 'status message',
        clear => 1|0,
    );

=item video

video namespace of the API (See L<WWW::Facebook::API::Video>).

=back

=head1 ATTRIBUTE METHODS

These are methods to get/set the object's attributes.

=over

=item api_key( $new_api_key )

The developer's API key. If C<$ENV{'WFA_API_KEY'}> is set, all instances will
be initialized with its value. See the Facebook API documentation for more
information.

=item api_version( $new_version )

Which version to use (default is "1.0", which is the latest one supported
currently). Corresponds to the argument C<v> that is passed in to methods as a
parameter.

=item app_id()

The application id where your Facebook app is described, e.g.:

    http://www.facebook.com/apps/application.php?id=THIS_NUMBER

Remember, C<WWW::Facebook::API> is not that clairvoyant: You must first
set this number (when calling C<new()>) in order to use it.

=item app_path()

If using the Facebook canvas, the path to your application. For example if your
application is at http://apps.facebook.com/example/ this should be C<"example">.

=item apps_uri()

The apps uri for Facebook apps. The default is http://apps.facebook.com/.

=item callback( $new_default_callback )

The callback URL for your application. See the Facebook API documentation.
Just a convenient place holder for the value.

=item call_success( $is_success, $error_message )

Takes in two values, the first setting the object's last_call_success
attribute, and the second setting the object's last_error attribute. Returns
an array reference containing the last_call_success and last_error values, in
that order:

    my $response = $client->call_success( 1, undef );
    if ( $response->[0] == 1 ) {
        print 'Last call successful';
    }
    if ( not defined $response->[1] ) {
        print 'Error message is undefined';
    }

    $client->call_success( 0,'2: The service is not available at this time.');

    $response = $client->call_success;
    if ( not $response->[0] ) {
        print 'Last call unsuccessful';
    }
    if ( not defined $response->[1] ) {
        print "Error $response->[1]";
    }

The C<call> method calls this method, and shouldn't need to be called to set
anything, just to get the value later if C<throw_errors> is false.

=item config($filename)

Used when instantiating a new object to set the environment variables. The
file has a simple, BASH-style format:

    WFA_API_KEY_MYAPP=383378efa485934bc
    WFA_SECRET_MYAPP=234234ac902f340923
    WFA_SESSION_KEY_MYAPP=34589349abce989d
    WFA_DESKTOP_MYAPP=1

If the file is found, and the environment variables are already set, then the
variables will not be changed.

=item debug(0|1)

A boolean set to either true or false, determining if debugging messages
should be carped for REST calls. Defaults to 0.

=item desktop(0|1)

A boolean signifying if the client is being used for a desktop application.
If C<$ENV{'WFA_DESKTOP'}> is set, all instances will be initialized with its
value. Defaults to 0 otherwise. See the Facebook API documentation for more
information.

=item format('JSON'|'XML')

The default format to use if none is supplied with an API method call.
Currently available options are XML and JSON. Defaults to JSON.

=item last_call_success(1|0)

A boolean set to true or false, to show whether the last call was successful
or not. Called by C<call_success>. Defaults to 1.

=item last_error( $error_message )

A string holding the error message of the last failed call to the REST server.
Called by C<call_success>. Defaults to undef.

=item next( $new_default_next_url )

See the Facebook API documentation's Authentication Guide. Just a convenient
place holder for the value.

=item parse(1|0)

Defaults to 1. If set to true, the response returned by each method call will
be a Perl structure (see each method for the structure it will return). If it
is set to 0, the response string from the server will be returned. (The
response string is unescaped if the 'desktop' attribute is false).

=item popup( $popup )

See the Facebook API documentation's Authentication Guide. Just a convenient
place holder for the value.

=item query( $query )

Stores the current query object to use (either L<CGI> or L<Apache::Request>)
but really anything that implements the C<param()> method can be used. B<N.B.
When using C<require_*> methods below, Apache::Request will croak because it
does not implement a redirect method.>

=item secret( $new_secret_key )

For a desktop application, this is the secret that is used for calling
C<< auth->create_token >> and C<< auth->get_session >>. For a web application,
secret is used for all calls to the API. If C<$ENV{'WFA_SECRET'}> is set,
all instances will be initialized with its value. See the Facebook API
documentation under Authentication for more information.

=item server_uri( $new_server_uri )

The server uri to access the Facebook REST server. Default is
C<'http://api.facebook.com/restserver.php'>. Used to make calls to the
Facebook server, and useful for testing. See the Facebook API documentation. 

=item session_expires( $new_expires )

The session expire timestamp for the client's user. Automatically set when
C<< $client->auth->get_session >> is called. See the Facebook API
documentation.

=item session_key( $new_key )

The session key for the client's user. Automatically set when
C<< $client->auth->get_session >> is called. See the Facebook API documentation.

=item session_uid( $new_uid )

The session's uid for the client's user. Automatically set when
C<< $client->auth->get_session >> is called. See the Facebook API documentation.

=item skipcookie(0|1)

See the Facebook API documentation's Authentication Guide. Just a convenient
place holder for the value.

=item throw_errors(0|1)

A boolean set to either true of false, signifying whether or not to C<confess>
when an error is returned from the REST server.

=item ua

The L<LWP::UserAgent> agent used to communicate with the REST server.
The agent_alias is initially set to "Perl-WWW-Facebook-API/0.4.18".

=back

=head1 PUBLIC METHODS

=over

=item call( $method, %args )

The method which other submodules within L<WWW::Facebook::API> use
to call the Facebook REST interface. It takes in a string signifying the method
to be called (e.g., 'auth.getSession'), and key/value pairs for the parameters
to use:
    $client->call( 'auth.getSession', auth_token => 'b3324235e' );

For all calls, if C< parse > is set to true and an empty hash/array reference
is returned from facebook, nothing will be returned instead of the empty
hash/array reference.

=item generate_sig( params => $params_hashref, secret => $secret )

Generates a sig when given a parameters hash reference and a secret key.

=item get_add_url( %params )

Returns the URL to add your application with the parameters (that are given)
included. Note that the API key and the API version parameters are also
included automatically. If the C<next> parameter is passed in, it's
string-escaped. Used for platform applications:

    $response = $client->get_add_url( next => 'http://my.website.com' );

    # prints http://www.facebook.com/app.php?api_key=key&v=1.0
    #        &next=http%3A%2F%2Fmy.website.com
    print $response;

=item get_app_url

Returns the URL to your application, if using the Facebook canvas. Uses
<$client->app_path>, which you have to set yourself (See <app_path> below).

=item get_facebook_url( $subdomain )

Returns the URL to Facebook. You can specifiy a specific network as a
parameter:

    $response = $client->get_facebook_url( 'apps' );
    print $response;    # prints http://apps.facebook.com

=item get_infinite_session_url()

Returns the URL for the user to generate an infinite session for your
application:

    $response = $client->get_infinite_session_url;

    # prints http://www.facebook.com/codegen.php?api_key=key&v=1.0
    print $response;

From what I've seen, the session keys that Facebook returns don't expire
automatically, so as long as you don't call $client->auth->logout, you
shouldn't even need to worry about this.

=item get_login_url( %params )

Returns the URL to login to your application with the parameters (that are
defined) included. If the C<next> parameter is passed in, it's string-escaped:

    $response = $client->get_login_url( next => 'http://my.website.com' );

    # prints http://www.facebook.com/login.php?api_key=key&v=1.0
    #        &next=http%3A%2F%2Fmy.website.com
    print $response;

=item get_url( $type, @args )

Called by all the above C<get_*_url> methods above. C<$type> can be C<'login'>,
C<'app'>, C<'add'>, C<'facebook'>, C<'infinite_session'>, or C<'custom'>.
C<@args> contains the query parameters for the the cases when C<$type> is not
C<'app'> or C<'facebook'>. In the case of C<'custom'>, the first item in
C<@args> is the url path relative to the facebook website. All of the
C<get_*_url> methods correspond to the ones in the official PHP client.

=item log_string($params_hashref, $response)

Pass in the params and the response from a call, and it will make a formatted
string out of it showing the parameters used, and the response received.

=item redirect( $url, $query_object )

Called by C<require()> to redirect the user either within the canvas or
without. If no <$query_object> is defined, then whatever is in C<<
$client->query >> will be used. (See L<WWW::Facebook::API::Canvas>) If no
redirect is required, nothing is returned. That is the only case when there is
no return value. If a redirect B<is> required, there are two cases that are
covered:

=over 4

=item user not logged in

If there isn't a user logged in to Facebook's system, then a redirect to the Facebook
login page is printed to STDOUT with a next parameter to the appropriate page.
The redirect is called with the the CGI module that comes standard with perl.
The return value in this case is 1.

=item user logged in

If the user is logged in to Facebook, and a redirect is required, the
necessary FBML is returned: C<< <fb:redirect url="WHATEVER"> >>.
So the return value is the FBML, which you can then print to STDOUT.

=back


=item require_add( $query )

Redirects the user to what C<get_add_url()> returns. See C<require()> below
for the C<$query> parameter.

=item require_frame( $query )

Redirects the user to what C<get_login_url( canvas => '1' )> returns. See
C<require()> below for the C<$query> parameter.

=item require_login( $query )

Redirects the user to what C<get_login_url()> returns. See C<require()> below
for the C<$query> parameter.

=item require( $what, $query )

The official PHP client has C<require_*> methods that take no arguments.
Logically, you better know what you want to require when you call each of
them, so this API consolidates them into one method. The valid values for
C<$what> are C<'add'>, C<'frame'>, and C<'login'>. C<$query> is the query
object to use (most likely L<CGI>). If C<$query> is undefined, the value of
C< $client->query >> is used.

=item session( uid => $uid, key => $session_key, expires => $session_expires )

Sets the C<user>, C<session_key>, and C<session_expires> all at once.

=item unescape_string($escaped_string)

Returns its parameter with all the escape sequences unescaped. If you're using
a web app, this is done automatically to the response.

=item verify_sig( sig => $expected_sig, params => $params_hashref )

Checks the signature for a given set of parameters against an expected value.

=back

=head1 PRIVATE METHODS

=over

=item _add_url_params( %params )

Called by both C<get_login_url> and C<get_add_url> to process any of their
parameters. Prepends the api_key and the version number as parameters and
returns the parameter string.

=item _check_values_of($params_hashref)

Makes sure all the values of the C<$params_hashref> that need to be set are
set. Uses the defaults for those values that are needed and not supplied.

=item _format_and_check_params( $method, %args )

Format method parameters (given in C<%args>) according to Facebook API
specification. Returns a list of items: A hash reference of the newly
formatted params (based on C<%params>) and the raw data (and filename, if
passed in) if the call is a photo or video upload:

    ($params, $raw_data, $filename) = $self->_format_and_check_params( $method, %args );

=item _has_error_response( $response )

Determines if the response is an error, and logs it appropriately. Returns
true if response is an error, false otherwise.

=item is_empty_response( $response )

Determines if the response is an empty hash or array reference. Returns true
if the response is empty, false otherwise.

=item _post_request( $params_hashref, $sig, $raw_data, $filename )

Used by C<call> to post the request to the REST server and return the
response. C<$raw_data> and C<$filename> are used when uploading a photo or
video to Facebook.

=item _parse($string)

Parses the response from a call to the Facebook server to make it a Perl data
structure, and returns the result.

=item _parser()

Returns a new instance of JSON::Any.

=item _reformat_response( $params, $response )

Reformats the response according to whether the app is a desktop app, if the
response should be parsed (i.e., changed to a Perlish structure), if the
response is empty, etc. Returns the reformatted response.

=back

=head1 DIAGNOSTICS

=over

=item Unable to load JSON module for parsing: %s

L<JSON::Any> was not able to load one of the JSON modules it uses to parse
JSON. Please make sure you have one (of the several) JSON modules it can use
installed.

=item Error during REST call: %s

This means that there's most likely an error in the server you are using to
communicate to the Facebook REST server. Look at the traceback to determine
why an error was thrown. Double-check that C<server_uri> is set to the right
location.

=item Cannot create namespace %s: %s

Cannot create the needed subclass method. Contact the developer to report.

=item Cannot create attribute %s: %s

Cannot create the needed attribute method. Contact the developer to report.

=item _format_and_check_params must be called in list context!

You're using a private method call and you're not calling it in list context.
It returns a list of items, all of which should be interesting to you.

=item Cannot open %s

Cannot open the configuration file. Make sure the filename is correct and that
the program has the appropriate permissions.

=item Cannot close %s

Cannot close the configuration file. Make sure the filename is correct and
that the program has the appropriate permissions.

=back

=head1 FAQ

=over

=item Id numbers returned by Facebook are being rounded. What is the problem?

The JSON module that is installed on your system is converting the numbers to
Perl and is losing precision in the process. Make sure you have the latest
L<JSON::XS> module installed or L<JSON::DWIW> (any recent version of either
should work).

=item How do I run the examples in the examples directory?

There are two types of examples in the examples directory, desktop-based and
web-based. With desktop-based, the api key and secret key are prompted for on
STDIN, and then the user's browser is opened and directed to the Facebook
log in page. Currently, the desktop-based examples pause for 20 seconds to
allow for the user to enter in their credentials.

With web-based, you have to pass in the api key, secret key, and app path to
the constructor, and then place the script at the callback url you specified
in the Facebook setup for your application. For instance, when using the
web-based example, you might have the following callback url (note the
trailing slash):
    
    http://www.example.com/facebook-canvas-json/

You have to make sure the required Perl modules are in the C<@INC> path for
the web server process, otherwise there will be a 500 Internal Server error.
The easiest way to do that is to put the following at the top of the example
script (as long as "path-to-perl5-libs" is readable by the web server
process):

    use lib "path-to-perl5-libs";

=item I'm getting the "Multiple values for %s" error from WFA::Canvas. Help?

This usually means that your forms are using GET rather than POST to Facebook
URLs. Change your forms to use POST and the problem should be resolved. (See
RT#31620 and RT#31944 for more information).

=back

=head1 CONFIGURATION AND ENVIRONMENT

WWW::Facebook::API requires no configuration files or environment variables.

=head1 DEPENDENCIES

L<version>
L<Crypt::SSLeay>
L<Digest::MD5>
L<JSON::Any>
L<Time::HiRes>
L<LWP::UserAgent>

=head1 INCOMPATIBILITIES

None.

=head1 BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to
C<bug-www-facebook-api@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.

=head1 SOURCE REPOSITORY

http://github.com/unobe/perl-wfa/tree/master

=head1 TESTING

There are some live tests included, but they are only run if the following
environment variables are set:
    WFA_API_KEY_TEST
    WFA_SECRET_TEST
    WFA_SESSION_KEY_TEST

Additionally, if your app is a desktop one, you must set C<WFA_DESKTOP_TEST>.
Also, the session key must be valid for the API key being used.

To enable POD coverage and POD formattings tests, set C<PERL_TEST_POD> to
true. To enable L<Perl::Critic> tests, set C<_PERL_TEST_CRITIC> to true.

=head1 AUTHOR

David Romano  C<< <unobe@cpan.org> >>

=head1 CONTRIBUTORS

Anthony Bouvier C<< none >>

Clayton Scott C<< http://www.matrix.ca >>

David Leadbeater C<< http://dgl.cx >>

Derek Del Conte C<< derek@delconte.org >>

Gisle Aas C<< none >>

J. Shirley C<< <jshirley@gmail.com> >>

Jim Spath C<< <jspath@gmail.com> >>

Kevin Riggle C<< none >>

Larry Mak C<< none >>

Louis-Philippe C<< none >>

Matt Sickler C<< <imMute@mail.msk3.ath.cx> >>

Nick Gerakines C<< <nick@socklabs.com> >>

Olaf Alders C<< <olaf@wundersolutions.com> >>

Patrick Michael Kane C<< <pmk@wawd.com> >>

Ryan D Johnson C<< ryan@innerfence.com >>

Sean O'Rourke C<< <seano@cpan.org> >>

Shawn Van Ittersum C<< none >>

Simon Cavalletto C<< <simonm@cavalletto.org> >>

Skyler Clark C<< none >>

Thomas Sibley C<< <tsibley@cpan.org> >>

=head1 LICENSE AND COPYRIGHT

Copyright (c) 2007-2010, David Romano C<< <unobe@cpan.org> >>. All rights reserved.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.

=head1 DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.