예제 #1
0
		$dataInsert['lname'] = $lname;
		$dataInsert['tw_name'] = $content->screen_name;
		$dataInsert['avatar'] = $content->profile_image_url;
		$dataInsert['tw_oauth_token'] = $access_token['oauth_token'];
		$dataInsert['tw_oauth_token_secret'] = $access_token['oauth_token_secret'];


		$user = $DB->selectWhatWhere("*", "tw_id = " . $content->id);
		$update_success = 0;
		$user_id = 0;
		if (empty($user)) { 
			$update_success = $DB->addItemsArray($dataInsert);
			$user_id = $DB->getLastId(); 
		} else {
			$user_id = $user[0]["users"]["id"];
			$update_success = $DB->updateWhatWhereArray2($dataInsert, "id = " . $user_id);
		}
		if ($update_success == 0) {
			$_SESSION['status'] = 'error';			
		} else {			
			$_SESSION['user_id'] = $user_id;
			$_SESSION['twitter_uid'] = $content->id;
		}
		header('Location: ./index.php');
	} else {
		header('Location: ./clearsessions.php');
	}
	
} else {
	
	$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);