mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 09:42:57 -07:00
Update Facebook Graph API version
This commit is contained in:
parent
8407f27fed
commit
d045fd5834
2 changed files with 11 additions and 10 deletions
|
@ -45,7 +45,8 @@ __version__ = version.__version__
|
||||||
|
|
||||||
FACEBOOK_GRAPH_URL = "https://graph.facebook.com/"
|
FACEBOOK_GRAPH_URL = "https://graph.facebook.com/"
|
||||||
FACEBOOK_OAUTH_DIALOG_URL = "https://www.facebook.com/dialog/oauth?"
|
FACEBOOK_OAUTH_DIALOG_URL = "https://www.facebook.com/dialog/oauth?"
|
||||||
VALID_API_VERSIONS = ["2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9"]
|
VALID_API_VERSIONS = [
|
||||||
|
"2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12"]
|
||||||
VALID_SEARCH_TYPES = ["page", "event", "group", "place", "placetopic", "user"]
|
VALID_SEARCH_TYPES = ["page", "event", "group", "place", "placetopic", "user"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ class GraphAPI(object):
|
||||||
self.session = session or requests.Session()
|
self.session = session or requests.Session()
|
||||||
|
|
||||||
if version:
|
if version:
|
||||||
version_regex = re.compile("^\d\.\d$")
|
version_regex = re.compile("^\d\.\d{1,2}$")
|
||||||
match = version_regex.search(str(version))
|
match = version_regex.search(str(version))
|
||||||
if match is not None:
|
if match is not None:
|
||||||
if str(version) not in VALID_API_VERSIONS:
|
if str(version) not in VALID_API_VERSIONS:
|
||||||
|
@ -229,7 +230,7 @@ class GraphAPI(object):
|
||||||
try:
|
try:
|
||||||
headers = response.headers
|
headers = response.headers
|
||||||
version = headers["facebook-api-version"].replace("v", "")
|
version = headers["facebook-api-version"].replace("v", "")
|
||||||
return float(version)
|
return str(version)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise GraphAPIError("API version number not available")
|
raise GraphAPIError("API version number not available")
|
||||||
|
|
||||||
|
@ -369,24 +370,24 @@ class GraphAPIError(Exception):
|
||||||
self.code = None
|
self.code = None
|
||||||
try:
|
try:
|
||||||
self.type = result["error_code"]
|
self.type = result["error_code"]
|
||||||
except:
|
except (KeyError, TypeError):
|
||||||
self.type = ""
|
self.type = ""
|
||||||
|
|
||||||
# OAuth 2.0 Draft 10
|
# OAuth 2.0 Draft 10
|
||||||
try:
|
try:
|
||||||
self.message = result["error_description"]
|
self.message = result["error_description"]
|
||||||
except:
|
except (KeyError, TypeError):
|
||||||
# OAuth 2.0 Draft 00
|
# OAuth 2.0 Draft 00
|
||||||
try:
|
try:
|
||||||
self.message = result["error"]["message"]
|
self.message = result["error"]["message"]
|
||||||
self.code = result["error"].get("code")
|
self.code = result["error"].get("code")
|
||||||
if not self.type:
|
if not self.type:
|
||||||
self.type = result["error"].get("type", "")
|
self.type = result["error"].get("type", "")
|
||||||
except:
|
except (KeyError, TypeError):
|
||||||
# REST server style
|
# REST server style
|
||||||
try:
|
try:
|
||||||
self.message = result["error_msg"]
|
self.message = result["error_msg"]
|
||||||
except:
|
except (KeyError, TypeError):
|
||||||
self.message = result
|
self.message = result
|
||||||
|
|
||||||
Exception.__init__(self, self.message)
|
Exception.__init__(self, self.message)
|
||||||
|
|
|
@ -1453,7 +1453,7 @@ class FACEBOOK(Notifier):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Request user access token
|
# Request user access token
|
||||||
api = facebook.GraphAPI(version='2.5')
|
api = facebook.GraphAPI(version='2.12')
|
||||||
response = api.get_access_token_from_code(code=code,
|
response = api.get_access_token_from_code(code=code,
|
||||||
redirect_uri=redirect_uri + '/facebookStep2',
|
redirect_uri=redirect_uri + '/facebookStep2',
|
||||||
app_id=app_id,
|
app_id=app_id,
|
||||||
|
@ -1461,7 +1461,7 @@ class FACEBOOK(Notifier):
|
||||||
access_token = response['access_token']
|
access_token = response['access_token']
|
||||||
|
|
||||||
# Request extended user access token
|
# Request extended user access token
|
||||||
api = facebook.GraphAPI(access_token=access_token, version='2.5')
|
api = facebook.GraphAPI(access_token=access_token, version='2.12')
|
||||||
response = api.extend_access_token(app_id=app_id,
|
response = api.extend_access_token(app_id=app_id,
|
||||||
app_secret=app_secret)
|
app_secret=app_secret)
|
||||||
|
|
||||||
|
@ -1479,7 +1479,7 @@ class FACEBOOK(Notifier):
|
||||||
|
|
||||||
def _post_facebook(self, **data):
|
def _post_facebook(self, **data):
|
||||||
if self.config['group_id']:
|
if self.config['group_id']:
|
||||||
api = facebook.GraphAPI(access_token=self.config['access_token'], version='2.5')
|
api = facebook.GraphAPI(access_token=self.config['access_token'], version='2.12')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
api.put_object(parent_object=self.config['group_id'], connection_name='feed', **data)
|
api.put_object(parent_object=self.config['group_id'], connection_name='feed', **data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue