Does not work with the rest of my code, yet this does;
Which is just a direct snippet from the larger cookie piece of code.
From what I can tell it's not using the stored cookies either (but that could be for other reasons) which means there must be a problem with this snippet and the larger piece of code, which I have included below.
get('account/rate_limit_status');
$remaininghits = $apistatus->remaining_hits;
if($remaininghits >= 50){
$param = array('count' => 1);
$mostrecenttweet = $connection->get('statuses/user_timeline', $param);
$userinfo = $connection->get('account/verify_credentials');
$uid = $userinfo->id;
$uname = $userinfo->screen_name;
$tweetcount = $userinfo->statuses_count;
$resettime = $apistatus->reset_time;
$mostrecentid = $mostrecenttweet[0]->id_str;
$SQL = "SELECT uid FROM users WHERE uid = '$uid'";
$result = mysql_query($SQL);
if(mysql_num_rows($result) == false){
$debug = 'first entry';
$store = "INSERT INTO users (uid, uname, tweetcount, mostrecentid, count, debug) VALUES ('$uid', '$uname', '$tweetcount', '$mostrecentid', 1, '$debug')";
mysql_query($store);
$id = md5('=a!-nd'.$uid);
$store = "INSERT INTO notes (id, uid, tid, note, hidden) VALUES ('$id', '$uid', '0', 'Your very first note, welcome!', 0)";
mysql_query($store);
for($page = 1; $page <= 16; ++$page){
$params = array('page' => $page, 'count' => 200);
$content = $connection->get('statuses/user_timeline', $params);
foreach($content as $post){
$ctid = $post->id_str;
$id = md5('=a!-nd'.$ctid);
if(preg_match('(^(Note to self|NTS)\W*|#NTS$)', $post->text)){
$title = preg_replace('(^(Note to self|NTS)\W*|#NTS$)', '', $post->text);
$store = "INSERT INTO notes (id, uid, tid, note, hidden) VALUES ('$id', '$uid', '$ctid', '$title', 0)";mysql_query($store);}
}}
}
else{
$debug = 'already registered';
$sql = "SELECT mostrecentid, count, tweetcount FROM users WHERE uid = '$uid'";
$queryresult = mysql_query($sql);
$result = mysql_fetch_array($queryresult);
$currentcount = $result['count'] + 1;
$ltid = $result['mostrecentid'];
$tweetcountold = $result['tweetcount'];
$tweetsbetween = $tweetcount - $tweetcountold;
$pageno = ceil($tweetsbetween / 200);
for($page = 1; $page <= $pageno; ++$page){
$params = array('since_id' => $ltid, 'page' => $page);
$content = $connection->get('statuses/user_timeline', $params);
foreach($content as $post){
$ctid = $post->id_str;
$id = md5('=a!-nd'.$ctid);
$SQL = "SELECT uid, tid FROM notes WHERE uid = '$uid' AND tid = '$ctid'";
$result = mysql_query($SQL);
if(mysql_num_rows($result) == false){
if(preg_match('(^(Note to self|NTS)\W*|#NTS$)', $post->text)){
$title = preg_replace('(^(Note to self|NTS)\W*|#NTS$)', '', $post->text);
$store = "INSERT INTO notes (id, uid, tid, note, hidden) VALUES ('$id', '$uid', '$ctid', '$title', 0)";
mysql_query($store);
}}}}
$updateuser = "UPDATE users SET tweetcount = '$tweetcount', uname = '$uname', mostrecentid = '$mostrecentid', count = '$currentcount', debug = '$debug' WHERE uid = '$uid'";
mysql_query($updateuser);
}
$notes = array();
$SQL = "SELECT id, note FROM notes WHERE uid = '$uid' AND hidden = 0 ORDER BY tid ASC";
$results = mysql_query($SQL);
while($rows = mysql_fetch_array($results)){
$notes[] = $rows['note'].'✓
';
}
$notesdone = array();
$SQL = "SELECT id, note FROM notes WHERE uid = '$uid' AND hidden = 1 ORDER BY tid DESC LIMIT 0, 5 ";
$results = mysql_query($SQL);
while($rows = mysql_fetch_array($results)){
$notesdone[] = $rows['note'].'
';
}
}
else{
$notes = 'You dont have enough API calls to use this, please wait for your reset at '.$resettime;
}
mysql_close($db_handle);
/* Include HTML to display on the page. */
include('html.inc');
?>