Permalink
Browse files

extending group examples

  • Loading branch information...
1 parent afb4d48 commit f85472eb97e0ca166b9c685fc2e3f92f83f90d3f @spazm committed Dec 12, 2012
Showing with 76 additions and 0 deletions.
  1. +41 −0 examples/show_group_event_information.pl
  2. +35 −0 examples/show_group_events.pl
View
41 examples/show_group_event_information.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+#ABSTRACT: Example Demonstrating Facebook::Graph::Cmdline life cycle
+
+# show_group_information.pl:
+# Demonstrates Facebook::Graph::Cmdline life cycle
+#
+# Initializes Facebook::Graph::Cmdline from a yaml
+# configfile(facebook.yml), creates and saves an
+# access token, requests and prints information
+# about a group (LA Perl Mongers)
+
+use warnings;
+use strict;
+use v5.10.0;
+
+use Data::Dumper;
+use Facebook::Graph::Cmdline;
+my $fb = Facebook::Graph::Cmdline->new_with_config(
+ configfile => 'facebook.yml' );
+
+unless ( $fb->verify_token() )
+{
+ my $token = $fb->token();
+ $fb->save_token();
+}
+
+my $lapm_group_id = '119158178096277';
+my $events = $fb->fetch("$lapm_group_id/events");
+
+#More info on the first event returned from search
+my $next_event_id = $events->{data}[0]->{id};
+my $next_event = $fb->fetch($next_event_id);
+say "Details:";
+say "$_ : $next_event->{$_}" for qw( name start_time location description );
+for my $rsvp qw(attending maybe declined)
+{
+ my $reply = $fb->fetch("$next_event_id/$rsvp")->{data};
+ say "$rsvp: ", scalar @$reply;
+ say "\t$_->{name}" for @$reply;
+}
View
35 examples/show_group_events.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+#ABSTRACT: Example Demonstrating Facebook::Graph::Cmdline life cycle
+
+# show_group_information.pl:
+# Demonstrates Facebook::Graph::Cmdline life cycle
+#
+# Initializes Facebook::Graph::Cmdline from a yaml
+# configfile(facebook.yml), creates and saves an
+# access token, requests and prints information
+# about a group (LA Perl Mongers)
+
+use warnings;
+use strict;
+use v5.10.0;
+
+use Data::Dumper;
+use Facebook::Graph::Cmdline;
+my $fb = Facebook::Graph::Cmdline->new_with_config(
+ configfile => 'facebook.yml' );
+
+unless ( $fb->verify_token() )
+{
+ my $token = $fb->token();
+ $fb->save_token();
+}
+
+my $lapm_group_id = '119158178096277';
+my $events = $fb->fetch("$lapm_group_id/events");
+#print Dumper $events;
+say "Next five events:";
+foreach my $event ( @{$events->{data}}[0..4])
+{
+ say join("\t", $event->{name}, $event->{start_time});
+}

0 comments on commit f85472e

Please sign in to comment.