in reply to Post Email address as CGI Parameter

How can I post an email ID via URL via CGI redirect?

Could you elaborate on this please? What is an email ID (I don't see a mention in the Facebook::Graph docs)? Which URL? Could you show an example of what you want to do?

an easy way rather than using a Perl module

Perl modules fitting for the task usually make things easier than writing them yourself ;-)

  • Comment on Re: Post Email address as CGI Parameter

Replies are listed 'Best First'.
Re^2: Post Email address as CGI Parameter
by doubledecker (Scribe) on Jan 06, 2015 at 18:28 UTC
    http://somedomain.com/cgi/register.cgi?login=$login&id=$user->{'id'}&e +mail=$user->{'email'}

    In the above code, I am passing an argument email with some email address fetched from facebook profile. However, when I dump those vars, I am not getting the value of email.

    Moreover, using Facebook::Graph::Query, we can get first_name, last_name, name, email by specifying them as fields

      Where do you dump the vars, in register.cgi or in the script accessing the URL? Could you provide some sample code that reproduces the problem? I know what I mean. Why don't you?

      Taking a guess based on the information you've provided so far: are you perhaps looking for URI?

      use URI; my $uri=URI->new("http://somedomain.com/cgi/register.cgi"); $uri->query_form(login=>"somelogin", id=>12345, email=>'foo@bar.com'); print "$uri\n"; __END__ http://somedomain.com/cgi/register.cgi?login=somelogin&id=12345&email= +foo%40bar.com

      How to send a redirect with CGI is in its documentation, with sample code ("Generating a Redirection Header"). If you do that, take care not to print out a regular header() as well.

        Thank you for your inputs. However, I have nearly 10+ fields to be sent and I don't think it makes any sense to send it via URL. Here is the code I'm working on....

        #!/usr/bin/perl use strict; use HTTP::Request::Common; use CGI; use Facebook::Graph; use Data::Dumper; my $APP_ID = 'SOME_ID'; my $SECRET = 'SOME_SECRET_CODE'; my $POSTBACK_URL = "http://goto.this.domain/postback.pl"; my $fb = Facebook::Graph->new( app_id => $APP_ID, secret => $SECRET, postback => $POSTBACK_URL, ); my $q = new CGI; my $params = $q->Vars; my $code = $params->{'code'}; $fb->request_access_token($code); my $token = $fb->access_token; $fb->request_extended_access_token($token); my $user = $fb->fetch('me'); #register the facebook data into my site to create a new profile; my $login = $user->{'name'}; $login =~ s/\s//g; my $sarah_bownds = $fb->query->find($user->{'id'}) ->select_fields(qw(id name email)) ->request ->as_hashref; my $default_picture = $fb->picture($user->{'id'})->get_square->uri_as +_string; my %register = ( login => $login, firstname => $user->{'first_name'}, lastname => $user->{'last_name'}, email => $user->{'email'}, action => 'register', id => $user->{'id'}, ); print $q->redirect("http://goto.this.domain/cgi/register.cgi?login=$lo +gin&id=$user->{'id'}&email=$user->{'email'}&msg=201&args=$sarah_bownd +s");