Skip to content

Instantly share code, notes, and snippets.

@seungwon0
Last active December 16, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seungwon0/5479816 to your computer and use it in GitHub Desktop.
Save seungwon0/5479816 to your computer and use it in GitHub Desktop.
shows facebook feed URL
#!/usr/bin/env perl
#
# facebook-feed.pl - shows facebook feed URL
#
# Shows facebook feed URL.
#
# Usage examples:
# % ./facebook-feed.pl girlsgeneration
# http://www.facebook.com/feeds/page.php?format=atom10&id=216732611680045
# % ./facebook-feed.pl http://www.facebook.com/trycatchpage
# http://www.facebook.com/feeds/page.php?format=atom10&id=301925689927032
#
# Seungwon Jeong <seungwon0@gmail.com>
#
# Copyright (C) 2013 by Seungwon Jeong
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
use perl5i::2;
use IO::All;
use Encode < decode_utf8 >;
use JSON < decode_json >;
use Readonly;
if ( @ARGV != 1 ) {
say "Usage: $PROGRAM_NAME FACEBOOK_ID";
exit 2;
}
my $facebook_id = $ARGV[0];
# Remove trailing '/'.
$facebook_id =~ s{ / $ }{}xms;
# http://www.facebook.com/trycatchpage -> trycatchpage
$facebook_id =~ s{ ^ .* / }{}xms;
my $url = 'http://graph.facebook.com/' . $facebook_id;
my $document = decode_utf8( io($url)->all );
my $graph_ref = decode_json($document);
Readonly my $FORMAT => 'atom10'; # or 'rss20'
my $feed_url
= "http://www.facebook.com/feeds/page.php?format=$FORMAT&id="
. $graph_ref->{id};
say $feed_url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment