Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versioning parameter & check if we get token #9

Merged
merged 3 commits into from
Feb 28, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/FoursquareAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class FoursquareApi {
/** @var String $TokenUrl The url for obtaining an auth token */
private $TokenUrl = "https://foursquare.com/oauth2/access_token";

// Edited Petr Babicka (babcca@gmail.com) https://developer.foursquare.com/overview/versioning
/** @var String $Version YYYYMMDD */
private $Version = '20120228';

/** @var String $ClientID */
private $ClientID;
/** @var String $ClientSecret */
Expand Down Expand Up @@ -72,6 +76,7 @@ public function GetPublic($endpoint,$params=false){
// Append the client details
$params['client_id'] = $this->ClientID;
$params['client_secret'] = $this->ClientSecret;
$params['v'] = $this->Version;
// Return the result;
return $this->GET($url,$params);
}
Expand All @@ -86,7 +91,8 @@ public function GetPublic($endpoint,$params=false){
public function GetPrivate($endpoint,$params=false,$POST=false){
$url = $this->BaseUrl . trim($endpoint,"/");
$params['oauth_token'] = $this->AuthToken;
if(!$POST) return $this->GET($url,$params);
$params['v'] = $this->Version;
if(!$POST) return $this->GET($url,$params);
else return $this->POST($url,$params);
}

Expand Down Expand Up @@ -243,7 +249,14 @@ public function GetToken($code,$redirect=''){
"code"=>$code);
$result = $this->GET($this->TokenUrl,$params);
$json = json_decode($result);
$this->SetAccessToken($json->access_token);
return $json->access_token;

// Petr Babicka Check if we get token
if (property_exists($json, 'access_token')) {
$this->SetAccessToken($json->access_token);
return $json->access_token;
}
else {
return 0;
}
}
}
}