Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Powershell 4.0, Facebook, and Cookies

$
0
0

This is driving me crazy!

I have a script that's been working for quite a while and recently stopped working. It logs into Facebook and checks to see if there are new notifications. Simple enough.

It recently stopped working. I think it's because of either XSS limitations on Facebook.com or because of something else.

During some of my debugging sessions (I'm a Powershell Noob!), I saw that the site may need to have cookies enabled. I'm using a session variable, but it still doesn't work.

I've seen this message a few times in some of the areas of the variables I'm creating:

Cookies Required

Cookies are not enabled on your browser. Please enable cookies in your browser preferences to continue.

 

Here's what I'm doing:

$r=Invoke-WebRequest http://www.facebook.com/login.php -SessionVariable fb
$form = $r.Forms[0]
$form.Fields["email"]="USERNAME"
$form.Fields["pass"]="PASSWORD"
$r=Invoke-WebRequest-Uri("http://www.facebook.com/login.php")-WebSession $fb -Method POST -Body $form.Fields
$countval = $r.ParsedHtml.getElementById("mercurymessagesCountValue").innerHTML"COUNTVAL="+$countval

Any ideas? When using Invoke-WebRequest, does the virtual browser have cookies enabled?

Viewing all articles
Browse latest Browse all 6937

Trending Articles