scrap_kisel.php 2.29 KB
<?php

include('kisel.conf.php');
include('KiselScrap.php');

#$arrinqtelco = array('customerId' => '08122027896',
#			'product' => 'SI10',
#			'inquiry' => 'Inquiry',
#			'_sourcePage' => 'fRCY-X8ZXOIcbgrf1BkkxBM7KTI7S6exLVsnXnUiXn8=',
#			'__fp' => 'wIlI6mnh04Y='
#		);



$kisel = new KiselScrap();

$redis = new Redis();
$redis->connect($redis_url);
$kisel->setSessionId($redis->get($redis_prefix.'01.sessionid'));

// get querystring 
$kisel->setTrxParam($_REQUEST['reqid'], $_REQUEST['msisdn'], $_REQUEST['product']);
$arrinqtelco = array('customerId' => $kisel->msisdn,
			'product' => $kisel->product,
			'inquiry' => 'Inquiry',
			'_sourcePage' => 'fRCY-X8ZXOIcbgrf1BkkxBM7KTI7S6exLVsnXnUiXn8=',
			'__fp' => 'wIlI6mnh04Y='
);

$kisel->setRandomUserAgent();

$log = "";
// Format the date and time
$date = date("Y-m-d H:i:s");
$fd = fopen("scrapper_kisel.log", "a+");


$log = "[$date] Step-1 : get welcome page\n";
$log .= "--------------------------------\n";
$kisel->get_page($welcome_url);
if(!$kisel->session_status) {
	print "masuk";
	$log .= "Error Session Invalid. Please input session";
	$err = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";	
	$err .= "<trx_response>\n";
	$err .= "<product>".$_REQUEST['product']."</product>\n";
	$err .= "<msisdn>".$_REQUEST['msisdn']."</msisdn>\n";
	$err .= "<info>SESSION INVALID !!!</info>\n";
	$err .= "</trx_response>";
	print $err;
}
sleep(1);
if($kisel->session_status) {
	$log .= "[$date] Step-2 : get purchase telco page\n";
	$log .= "--------------------------------\n";
	$kisel->get_page($purchasetelco_url);
	#$prevbal = array();
	#$prevbal = $kisel->balance();
	#print_r($prevbal);
	sleep(1);

	$log .= "[$date] Step-3 : send inquiry telco\n";
	$log .= "--------------------------------\n";
	$kisel->send_form($purchasetelco_url, $purchasetelco_url, $arrinqtelco);
	$kisel->parseResponse("//table[@class='tblogin']/tbody/tr/td",0);
	sleep(1);

	$log .= "[$date] Step-4 : send purchase telco\n";
	$log .= "--------------------------------\n";
	
	$arrinqtelconext = array('goToPin' => 'next',
				'_sourcePage' => $kisel->source_page,
				'__fp' => $kisel->fp
			);

	$kisel->send_form($purchasetelco_url, $purchasetelco_url, $arrinqtelconext);
	$kisel->parseResponse("//table[@class='tblogin']/tbody/tr/td",1);
	$kisel->printResponseXML();

	fwrite($fd, $log);
	fclose($fd);
}

?>