I need same job done from an app

sktanmoy

Active Member
Licensed User
Longtime User
Let me post my PHP file first

B4X:
<?php
$logindata = array (
'loginname'      =>      'username@gmail.com',
'loginpass'      =>      'password'
);

$loginurl = "https://mydomain.com/corporate/logincheck.php";

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "../cookie.txt");
curl_setopt($ch, CURLOPT_URL, $loginurl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $logindata);

ob_start();      // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean();  // stop preventing output

curl_close ($ch);
unset($ch);

$requesturl = "https://mydomain.com/corporate/nextstep.php";
$requestdata = array('field_1' => '9901713411851', 'field_2' => '56698', 'field_3' => '100');

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "../cookie.txt");
curl_setopt($ch, CURLOPT_URL, $requesturl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestdata);

$buf2 = curl_exec ($ch);

curl_close ($ch);

echo "<PRE>".htmlentities($buf2);
?>


I can send data POST data using httputils2 easily but don't know how to save cookie and use those later. Anyone please :sign0085: me.
 

sktanmoy

Active Member
Licensed User
Longtime User
Solved

Just noticed that Httputils2 handled cookies itself, no extra effort was needed. B4A, Erel & Httputils together are awesome.:sign0060:
 
Upvote 0
Top