--- 3m-810.pl 2009/06/23 12:19:30 43 +++ 3m-810.pl 2009/06/23 13:10:18 44 @@ -8,6 +8,7 @@ use Carp qw/confess/; use Getopt::Long; use File::Slurp; +use JSON; use IO::Socket::INET; @@ -84,12 +85,15 @@ if ( my $path = static( $client,$1 ) ) { warn ">> $path"; } elsif ( $method =~ m{/scan} ) { - print $client "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n"; + my $callback = $1 if $method =~ m{\?callback=([^&;]+)}; my $tags = scan_for_tags(); - print $client "tags: ",dump($tags); my $json; - map { $json->{$_} = decode_tag($_) } keys %$tags; - print $client "decoded: ",dump( $json ); + map { + my $d = decode_tag($_); + $d->{sid} = $_; + push @{ $json->{tags} }, $d; + } keys %$tags; + print $client "HTTP/1.0 200 OK\r\nContent-Type: application/x-javascript\r\n\r\n$callback(", to_json($json), ")\r\n"; } else { print $client "HTTP/1.0 404 Unkown method\r\n"; }