在Web浏览器中运行的Perl脚本

时间:2013-08-29 13:35:07

标签: perl browser

        #!/usr/bin/perl 

        use WWW::Facebook::API;
        use WWW::Facebook::API::Auth;
        use HTTP::Request;
        use LWP;
        use Data::Dumper;

        print "Content-type: text/html\n\n";

        my $facebook_api      = '------------';
        my $facebook_secret   = '-----------------';
        my $facebook_clientid = '--------------------------------';

        print "$facebook_api<br/>";
        print "$facebook_secret<br/>";
        print "$facebook_clientid<br/>";

        my $client = WWW::Facebook::API->new(
        desktop         => 1,
        api_version     => '1.0',
        api_key         => $facebook_api,
        secret          => $facebook_secret,   
        );

        print "$Client<br/>";

        $client->app_id($facebook_clientid);

        $token = $client->auth->login(browser=> '/usr/bin/firefox');    
        $client->auth->get_session($token);

        print "$Client<br/>";

        $response = $client->fql->query( query => 'SELECT name, email, birthday, username, first_name, last_name, pic FROM user WHERE uid = me()');
        print join "\n Name:",  sort map { $_->{name} } @$response;
        print "</br>\n";

         local $SIG{INT} = sub
        {
        print "Logging out of Facebook";
        my $r = $client->auth->logout;
        exit(1);
        }; 

我在网络浏览器Firefox中运行此脚本。我得到的只是api的秘密,客户端ID后屏幕上什么都没有。我需要运行它并获取facebook数据

使用ubuntu 12.04,apache服务器。

0 个答案:

没有答案