BuzzerBeater Forums

BBAPI Support > PHP How to keep cookie

PHP How to keep cookie

Set priority
Show messages by
Message deleted
This Post:
11
199456.2 in reply to 199456.1
Date: 10/26/2011 9:31:17 AM
Overall Posts Rated:
12061206
Maybe it isn't the best way but for me it works ;-)

Writing cookies:


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://bbapi.buzzerbeater.com/login.aspx?login=XXX&code=YYY');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIEJAR, '[PATH]/cookies.txt');
$source = curl_exec($curl);
curl_close($curl);
echo $source;

// XXX - login
// YYY - access code
// [PATH] - path to file cookies.txt


Using cookies:


$curl2 = curl_init();
curl_setopt($curl2, CURLOPT_URL, "http://bbapi.buzzerbeater.com/countries.aspx");
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl2, CURLOPT_COOKIEFILE, '[PATH]/cookies.txt');
$source2 = curl_exec($curl2);
curl_close($curl2);
echo $source2;

// http://bbapi.buzzerbeater.com/countries.aspx - example of BBAPI page


Last edited by B.B.King at 10/26/2011 10:54:50 AM