diff --git a/data/interfaces/default/notification_config.html b/data/interfaces/default/notification_config.html
index 260c992d..d362ef70 100644
--- a/data/interfaces/default/notification_config.html
+++ b/data/interfaces/default/notification_config.html
@@ -136,14 +136,14 @@ from plexpy import helpers
cache: false,
async: true,
complete: function (xhr, status) {
- $("#notification-config-modal").html(xhr.responseText);
+ $('#notification-config-modal').html(xhr.responseText);
}
});
}
$('#osxnotifyregister').click(function () {
- var osx_notify_app = $("#osx_notify_app").val();
- $.get("/osxnotifyregister", { 'app': osx_notify_app }, function (data) { showMsg(" " + data, false, true, 3000); });
+ var osx_notify_app = $('#osx_notify_app').val();
+ $.get('/osxnotifyregister', { 'app': osx_notify_app }, function (data) { showMsg(' ' + data, false, true, 3000); });
})
$('#save-notification-item').click(function () {
@@ -163,12 +163,12 @@ from plexpy import helpers
});
$('#twitterStep1').click(function () {
- $.get("/twitterStep1", function (data) {window.open(data); })
- .done(function () { showMsg(" Confirm Authorization. Check pop-up blocker if no response.", false, true, 3000); });
+ $.get('/twitterStep1', function (data) {window.open(data); })
+ .done(function () { showMsg(' Confirm Authorization. Check pop-up blocker if no response.', false, true, 3000); });
});
$('#twitterStep2').click(function () {
- var twitter_key = $("#twitter_key").val();
- $.get("/twitterStep2", { 'key': twitter_key }, function (data) { showMsg(" " + data, false, true, 3000); });
+ var twitter_key = $('#twitter_key').val();
+ $.get('/twitterStep2', { 'key': twitter_key }, function (data) { showMsg(' ' + data, false, true, 3000); });
});
function disableFacebookRequest() {
@@ -182,8 +182,8 @@ from plexpy import helpers
$('#facebookStep1').click(function () {
doAjaxCall('set_notification_config', $(this), 'tabs', true);
- $.get("/facebookStep1", function (data) {window.open(data); })
- .done(function () { showMsg(" Confirm Authorization. Check pop-up blocker if no response.", false, true, 3000); });
+ $.get('/facebookStep1', function (data) { window.open(data); })
+ .done(function () { showMsg(' Confirm Authorization. Check pop-up blocker if no response.', false, true, 3000); });
});
$('#test_notifier').click(function () {
@@ -215,10 +215,10 @@ from plexpy import helpers
// Never send checkbox values directly, always substitute value in hidden input.
$('.checkboxes').click(function () {
var configToggle = $(this).data('id');
- if ($(this).is(":checked")) {
- $("#"+configToggle).val(1);
+ if ($(this).is(':checked')) {
+ $('#'+configToggle).val(1);
} else {
- $("#"+configToggle).val(0);
+ $('#'+configToggle).val(0);
}
});
diff --git a/plexpy/config.py b/plexpy/config.py
index 1564658b..afe81bf8 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -80,6 +80,7 @@ _CONFIG_DEFINITIONS = {
'EMAIL_ON_INTUP': (int, 'Email', 0),
'ENABLE_HTTPS': (int, 'General', 0),
'FACEBOOK_ENABLED': (int, 'Facebook', 0),
+ 'FACEBOOK_REDIRECT_URI': (str, 'Facebook', ''),
'FACEBOOK_APP_ID': (str, 'Facebook', ''),
'FACEBOOK_APP_SECRET': (str, 'Facebook', ''),
'FACEBOOK_TOKEN': (str, 'Facebook', ''),
diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py
index 9fb7ac30..a23f8b58 100644
--- a/plexpy/notifiers.py
+++ b/plexpy/notifiers.py
@@ -2020,22 +2020,10 @@ class Scripts(object):
class FacebookNotifier(object):
def __init__(self):
+ self.redirect_uri = plexpy.CONFIG.FACEBOOK_REDIRECT_URI
self.app_id = plexpy.CONFIG.FACEBOOK_APP_ID
self.app_secret = plexpy.CONFIG.FACEBOOK_APP_SECRET
self.group_id = plexpy.CONFIG.FACEBOOK_GROUP
-
- if plexpy.CONFIG.ENABLE_HTTPS:
- protocol = 'https'
- else:
- protocol = 'http'
-
- if plexpy.CONFIG.HTTP_HOST == '0.0.0.0':
- host = 'localhost'
- else:
- host = plexpy.CONFIG.HTTP_HOST
-
- self.redirect_url = '%s://%s:%i/facebookStep2' % (protocol, host, plexpy.CONFIG.HTTP_PORT)
-
def notify(self, subject, message):
if not subject or not message:
@@ -2048,7 +2036,7 @@ class FacebookNotifier(object):
def _get_authorization(self):
return facebook.auth_url(app_id=self.app_id,
- canvas_url=self.redirect_url,
+ canvas_url=self.redirect_uri + '/facebookStep2',
perms=['user_managed_groups','publish_actions'])
def _get_credentials(self, code):
@@ -2058,7 +2046,7 @@ class FacebookNotifier(object):
# Request user access token
api = facebook.GraphAPI(version='2.5')
response = api.get_access_token_from_code(code=code,
- redirect_uri=self.redirect_url,
+ redirect_uri=self.redirect_uri + '/facebookStep2',
app_id=self.app_id,
app_secret=self.app_secret)
access_token = response['access_token']
@@ -2072,7 +2060,7 @@ class FacebookNotifier(object):
plexpy.CONFIG.FACEBOOK_TOKEN = access_token
plexpy.CONFIG.write()
except Exception as e:
- logger.info(u"PlexPy Notifiers :: Error requesting Facebook access token: %s" % e)
+ logger.error(u"PlexPy Notifiers :: Error requesting Facebook access token: %s" % e)
return False
return True
@@ -2088,12 +2076,12 @@ class FacebookNotifier(object):
api.put_wall_post(profile_id=group_id, message=message)
logger.info(u"PlexPy Notifiers :: Facebook notification sent.")
except Exception as e:
- logger.info(u"PlexPy Notifiers :: Error sending Facebook post: %s" % e)
+ logger.warn(u"PlexPy Notifiers :: Error sending Facebook post: %s" % e)
return False
return True
else:
- logger.info(u"PlexPy Notifiers :: Error sending Facebook post: No Facebook Group ID provided.")
+ logger.warn(u"PlexPy Notifiers :: Error sending Facebook post: No Facebook Group ID provided.")
return False
def return_config_options(self):
@@ -2103,10 +2091,17 @@ class FacebookNotifier(object):
Facebook Developers to create a new app using advanced setup.
\
Step 2: Go to Settings > Advanced and fill in \
Valid OAuth redirect URIs with your PlexPy URL (i.e. http://localhost:8181).
\
- Step 3: Fill in the App ID and App Secret below.
\
- Step 4: Click the Request Authorization button below.',
+ Step 3: Fill in the PlexPy URL below with the exact same URL from Step 2.
\
+ Step 4: Fill in the App ID and App Secret below.
\
+ Step 5: Click the Request Authorization button below.',
'input_type': 'help'
},
+ {'label': 'PlexPy URL',
+ 'value': self.redirect_uri,
+ 'name': 'facebook_redirect_uri',
+ 'description': 'Your PlexPy URL. This will tell Facebook where to redirect you after authorization.',
+ 'input_type': 'text'
+ },
{'label': 'Facebook App ID',
'value': self.app_id,
'name': 'facebook_app_id',
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index d4f573f3..83da1b01 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -1312,7 +1312,7 @@ class WebInterface(object):
result = facebook._get_credentials(code)
# logger.info(u"result: " + str(result))
if result:
- return "Key verification successful, you may close this page now."
+ return "Key verification successful, PlexPy can send notification to Facebook. You may close this page now."
else:
return "Unable to verify key"