get access token

Get the access token after auth and make it a session variable.

$code=$_REQUEST[\'code\'];
$client_id=\'YOUR-CLIENT-ID\';
$client_secret=\'YOUR-CLIENT-SECRET\';
$redirect_uri=\'http:snippetlib.comfoursquare\';
$date=date(\"Ymd\");
session_start();

if (!isset($_SESSION[\'access_token\'])){
	$app_token_url = \"https:foursquare.comoauth2access_token?client_id=\" . $client_id .\"&client_secret=\" . $client_secret . \"&grant_type=authorization_code&redirect_uri=\" . $redirect_uri . \"&code=\" . $code ;
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $app_token_url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$foursquare_token = curl_exec($ch);
	curl_close($ch);
	
	 get the token and make it a session variable
	$array_token = json_decode($foursquare_token, true); 
	$token=$array_token[\'access_token\'];
	$access_token=$_SESSION[\'access_token\']=$token;
} else {
	$access_token=$_SESSION[\'access_token\'];
}