(PHP) Nectar Points

This little script logs you into your nectar account and retrieves how many points you have. The code is abit messy at the moment but it works.

Code written by muoi@mu0i

<?php
$username=”";
$password=”";
$gacookie=”./.cookie”;

$postdata=”j_username=$username&j_password=$password&j_identifier=USER_DB&rememberMeValue=Y”;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,”https://www.nectar.com/j_security_check”);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, “Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6″);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $gacookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $gacookie);
curl_setopt ($ch, CURLOPT_REFERER, ‘https://www.nectar.com/NectarLogin.snectar’);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
//echo $result;

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

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $gacookie);
curl_setopt($ch, CURLOPT_URL,”https://www.nectar.com/account/UserHome.snectar”);
curl_setopt ($ch, CURLOPT_REFERER, ‘https://www.nectar.com/NectarLogin.snectar’);
$result = curl_exec ($ch);
//echo $result;

preg_match_all(”|title=\”View your account details\”>(.*) points</a>|U”, $result, $match);

//echo “<pre>”;
//print_r($match);
unlink($gacookie);
curl_close ($ch);

echo “you have “.$match[1][0].” nectar points<br /><br />”;
echo “this is real, data is queried from nectar.com”;
exit;
?>