Skip to content

Commit 7dd509f

Browse files
authored
Merge pull request #54 from henriquemattos/master
Allow dynamic Facebook API version via Strategy parameters
2 parents 41916b9 + f0f95e0 commit 7dd509f

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.DS_Store
2-
2+
.idea

FacebookStrategy.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ class FacebookStrategy extends OpauthStrategy {
88
'scope' => 'email', // Default scope for necessary permissions
99
);
1010

11-
private $api_version = 'v12.0'; // Update to the latest supported version
11+
private $api_version = 'v17.0'; // Update to the latest supported version
1212

1313
public function request() {
14-
$url = "https://www.facebook.com/{$this->api_version}/dialog/oauth";
1514
$params = array(
1615
'client_id' => $this->strategy['app_id'],
1716
'redirect_uri' => $this->strategy['redirect_uri'],
1817
'scope' => $this->strategy['scope'],
1918
);
2019

20+
if (!empty($this->strategy['api_version'])) {
21+
$params['api_version'] = $this->strategy['api_version'];
22+
$this->api_version = $this->strategy['api_version'];
23+
}
24+
$url = "https://www.facebook.com/{$this->api_version}/dialog/oauth";
25+
2126
// Other optional parameters
2227
if (!empty($this->strategy['state'])) $params['state'] = $this->strategy['state'];
2328
if (!empty($this->strategy['response_type'])) $params['response_type'] = $this->strategy['response_type'];
@@ -114,6 +119,10 @@ private function me($access_token) {
114119
$fields = $this->strategy['fields'];
115120
}
116121

122+
if (!empty($this->strategy['api_version'])) {
123+
$this->api_version = $this->strategy['api_version'];
124+
}
125+
117126
$me = $this->serverGet(
118127
"https://graph.facebook.com/{$this->api_version}/me",
119128
array(

composer.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
"name": "opauth/facebook",
33
"description": "Facebook strategy for Opauth",
44
"keywords": ["authentication","auth","facebook"],
5-
"homepage": "http://opauth.org",
5+
"homepage": "https://opauth.org",
66
"license": "MIT",
77
"authors": [
88
{
99
"name": "U-Zyn Chua",
1010
"email": "[email protected]",
1111
"homepage": "http://uzyn.com"
12+
},
13+
{
14+
"name": "Henrique Mattos",
15+
"email": "[email protected]",
16+
"homepage": "https://www.visualworks.com.br"
1217
}
1318
],
1419
"require": {

0 commit comments

Comments
 (0)