perlwww-mechanize

WWW::Mechanize send custom HTTP headers


Hi im making a little program for open a webpage this webpage needs to receive my msisdn for allow me to receive the login, im trying to send it by this way

#!/usr/bin/perl

use WWW::Mechanize;

my $target = "http://www.example.domain/subscription/showsubscribe";

my $user_agent = 'Mozilla/5.0 (Linux; Android 4.2.2; es-us; SAMSUNG GT-I9195L Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Version/1.0 Chrome/18.0.1025.308 Mobile Safari/535.19';
my $phonenumber = 'XXXXXXXXXX';

my $mech = WWW::Mechanize->new(agent=>$user_agent);
$mech->add_header('x-msisdn'=> $phonenumber);

my $response = $mech->get($target);
die "Error at '$target'\n", $response->status_line, "\n
Aborting" unless $response->is_success;
print $mech->content;

$response = $mech->response;
for my $key ($response->header_field_names()) {
print "response[$key] = ", $response->header($key), "\n";

the X-msisdn variable i got reading in the forum from this page: http://mobiforge.com/design-development/useful-x-headers

any idea of how i can send the HTTP header?

thanks in advance!


Solution

  • ... $mech->add_header('x-msisdn'=> $phonenumber);

    any idea of how i can send the HTTP header?

    The header gets sent (check with wireshark or similar). Your problem is something different.