cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

php curl problem-- cookie not sending

From: net mastan <netmastan_at_hotmail.com>
Date: Mon, 18 Aug 2003 19:08:40 +0000

hi,
I am trying to login on https site and send txt message.Please see the
code,the following code will login me and shows welcome message. But the
next code does not recognised as logged in.It shows me login box. So, looks
like cookie is not sending correctly..

$txtUserID= "XXXX";
$txtPassword = "XXXX";
$txtMessage="Say Hello";
$mobile="#adhoc_XXXXXXX";

$logonfields =
"txtUserID=$txtUserID&txtPassword=$txtPassword&txtKeyCode=&url=/myvodafone/index.jsp&pcode=sol&pinfo=";
$sendmsgfields="recipients=$mobile&messageBody=$txtMessage&action=send&totalMsgs=";

$cookie_jar = tempnam('/tmp','cookie');
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1); // Get the header
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;MSIE 5.01;
Windows NT 5.0)");
curl_setopt($ch, CURLOPT_REFERER, "http://www.domain.com/index.jsp/");
curl_setopt($ch, CURLOPT_COOKIEJAR, "$cookie_jar");
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch,
CURLOPT_URL,"https://www.domain.com/knox/login_handler.jsp/");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$logonfields");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.domain.com/index.jsp/");
// upto here i can see welcome message,if i execute the next bit of code it
shows me login box

curl_setopt($ch, CURLOPT_HEADER, 1); // Get the header
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;MSIE 5.01;
Windows NT 5.0)");
curl_setopt($ch, CURLOPT_COOKIEFILE, "$cookie_jar");
curl_setopt($ch,
CURLOPT_URL,"http://web2txt.domain.com/yrweb2txt/messages/sendmessageuicontroller.jsp/");

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$sendmsgfields");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.domain.com/index.jsp/");

$result=curl_exec($ch);
curl_close($ch);

echo"$result";

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-08-18