doubledecker has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I am using Facebook::Graph and trying to gather user information from facebook profile. In this due course, How can I post an email ID via URL via CGI redirect? I thought of using Storable module to pack all the information in a variable but thought of finding an easy way rather than using a Perl module. any help is appreciated

Replies are listed 'Best First'.
Re: Post Email address as CGI Parameter
by Anonymous Monk on Jan 06, 2015 at 18:17 UTC
    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 ;-)

      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.

Re: Post Email address as CGI Parameter
by Anonymous Monk on Jan 07, 2015 at 09:08 UTC
    FYI, somedomain.com ... goto.this.domain ... the official example domain is example.com :)
Re: Post Email address as CGI Parameter
by Anonymous Monk on Jan 07, 2015 at 12:51 UTC
    Email addresses contain special characters that must be "escaped." Go look at any web-site that has a "mailto" link and look at the source-code of what has been sent to your browser. If possible, also look at the actual HTML text that you are sending to YOUR host. Any typo can cause the HTML not to be parsed correctly, with unpredictable results.
      CGI->escape() should take care of it
      $ perl -MCGI=escape -le " print escape(q/< > & ; ) ( [ ] escaped / ) " %3C%20%3E%20%26%20%3B%20%29%20%28%20%5B%20%5D%20escaped%20
      Email addresses in mailto: links do not need special characters like the @ escaped in the HTML. mailto: links that specify a subject, body, etc. do need those values escaped, see e.g. here. Email addresses in URLs do need to be escaped, one way to do that has already been shown above.
        Even more specific: mailto's are specified in RFC 6068 with some definitions coming from RFC 5322. Those specify the exact rules, a little complicated to summarize here, but for example the @ between the local-part and domain in the addresses shouldn't be escaped. The URI module claims to support the now obsolute mailto specification from RFC 2368.