Re: Curling a hotmail account

Stephen Pynenburg <[email protected]> Sat, 30 Jul 2016 18:59:28 -0400
Newsgroups gmane.comp.web.curl.php
Message-ID <CAPgVXYPns2sBuRUazcO8142MbUizSD9OSLk=sFE+RpS5uXFQeQ@mail.gmail.com>
--===============1882314639==
Content-Type: multipart/alternative; boundary=94eb2c05fefabbe0ad0538e251a6

--94eb2c05fefabbe0ad0538e251a6
Content-Type: text/plain; charset=UTF-8

A few things to look out for:
1) Make sure all the IDs in the URL you're POSTing to are up-to-date and
correct, i.e. hit the login page and parse the <form action="*"> out to get
the URL, don't use it hard-coded
2) Make sure you are POSTing a value for each field in the form - it
doesn't look like you have anything for the "keep me signed in" box or for
the submit button itself
3) Watch out for any Javascript that fires on clicking the login button.
See if the site works in your browser with JS disabled and base your curl
method off of that site
4) The login page might be setting session cookies, etc. before login -
make sure you tell curl to accept those (if any)

The page looks pretty complicated - you might have your work cut out for
you. You might want to step back and consider whether whatever you're
trying to do would be easier with POP3, IMAP, etc.

Anyway, hope this helps.

Stephen


On Sat, Jul 30, 2016 at 6:02 PM, Reda Lotfi <[email protected]> wrote:

> Hey,
>
> Curling hotmail.com using the following code returns a "username/password
> error" despite their correctness. Any debugging suggestion ?
>
>         $try = curl_init();
>         curl_setopt_array($try, array(CURLOPT_POST => true,
> CURLOPT_POSTFIELDS => "loginfmt=email&login=email&passwd=password",
> CURLOPT_URL => "
> https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&ct=1469906822&rver=6.6.6556.0&wp=MBI_SSL&wreply=https:%2F%2Foutlook.live.com%2Fowa%2F&id=292841&CBCXT=out&bk=1469906824&uaid=f317ac0874ff45cc9dcdc18d55ba5d58&pid=0",
> CURLOPT_FOLLOWLOCATION => true, CURLOPT_UNRESTRICTED_AUTH => true));
>         curl_exec($try);
>         curl_close($try);
>
> Regards,
> Reda
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>

--94eb2c05fefabbe0ad0538e251a6
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div><div><div>A few things to look ou=
t for:<br></div>1) Make sure all the IDs in the URL you&#39;re POSTing to a=
re up-to-date and correct, i.e. hit the login page and parse the &lt;form a=
ction=3D&quot;*&quot;&gt; out to get the URL, don&#39;t use it hard-coded<b=
r></div>2) Make sure you are POSTing a value for each field in the form - i=
t doesn&#39;t look like you have anything for the &quot;keep me signed in&q=
uot; box or for the submit button itself<br></div>3) Watch out for any Java=
script that fires on clicking the login button. See if the site works in yo=
ur browser with JS disabled and base your curl method off of that site<br><=
/div>4) The login page might be setting session cookies, etc. before login =
- make sure you tell curl to accept those (if any)<br><br></div>The page lo=
oks pretty complicated - you might have your work cut out for you. You migh=
t want to step back and consider whether whatever you&#39;re trying to do w=
ould be easier with POP3, IMAP, etc.<br><br></div>Anyway, hope this helps.<=
br><br></div>Stephen<br><div><div><div><div><div><div><div><br></div></div>=
</div></div></div></div></div></div><div class=3D"gmail_extra"><br><div cla=
ss=3D"gmail_quote">On Sat, Jul 30, 2016 at 6:02 PM, Reda Lotfi <span dir=3D=
"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">redal=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote=
" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">H=
ey,<br>
<br>
Curling <a href=3D"http://hotmail.com" rel=3D"noreferrer" target=3D"_blank"=
>hotmail.com</a> using the following code returns a &quot;username/password=
 error&quot; despite their correctness. Any debugging suggestion ?<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 $try =3D curl_init();<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 curl_setopt_array($try, array(CURLOPT_POST =3D&=
gt; true, CURLOPT_POSTFIELDS =3D&gt; &quot;loginfmt=3Demail&amp;login=3Dema=
il&amp;passwd=3Dpassword&quot;, CURLOPT_URL =3D&gt; &quot;<a href=3D"https:=
//login.live.com/ppsecure/post.srf?wa=3Dwsignin1.0&amp;ct=3D1469906822&amp;=
rver=3D6.6.6556.0&amp;wp=3DMBI_SSL&amp;wreply=3Dhttps:%2F%2Foutlook.live.co=
m%2Fowa%2F&amp;id=3D292841&amp;CBCXT=3Dout&amp;bk=3D1469906824&amp;uaid=3Df=
317ac0874ff45cc9dcdc18d55ba5d58&amp;pid=3D0" rel=3D"noreferrer" target=3D"_=
blank">https://login.live.com/ppsecure/post.srf?wa=3Dwsignin1.0&amp;ct=3D14=
69906822&amp;rver=3D6.6.6556.0&amp;wp=3DMBI_SSL&amp;wreply=3Dhttps:%2F%2Fou=
tlook.live.com%2Fowa%2F&amp;id=3D292841&amp;CBCXT=3Dout&amp;bk=3D1469906824=
&amp;uaid=3Df317ac0874ff45cc9dcdc18d55ba5d58&amp;pid=3D0</a>&quot;, CURLOPT=
_FOLLOWLOCATION =3D&gt; true, CURLOPT_UNRESTRICTED_AUTH =3D&gt; true));<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 curl_exec($try);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 curl_close($try);<br>
<br>
Regards,<br>
Reda<br>
<br>
<br>
_______________________________________________<br>
<a href=3D"http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php" rel=
=3D"noreferrer" target=3D"_blank">http://cool.haxx.se/cgi-bin/mailman/listi=
nfo/curl-and-php</a><br>
</blockquote></div><br></div>

--94eb2c05fefabbe0ad0538e251a6--

--===============1882314639==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KaHR0cDovL2Nv
b2wuaGF4eC5zZS9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vY3VybC1hbmQtcGhwCg==

--===============1882314639==--