diff options
Diffstat (limited to 'app/syndication/syndicators.py')
-rw-r--r-- | app/syndication/syndicators.py | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/app/syndication/syndicators.py b/app/syndication/syndicators.py index 89280e3..9393d4d 100644 --- a/app/syndication/syndicators.py +++ b/app/syndication/syndicators.py @@ -1,19 +1,13 @@ from django.conf import settings from django.test.client import Client -import urllib -from urllib import parse -from urllib.parse import urlencode -import subprocess -import warnings from twython import Twython from bs4 import BeautifulSoup from medium import Client as MediumClient -from jrnl.models import extract_images -from photos.models import LuxImage import flickrapi import facebook +from photos.models import LuxImage def absolute_urls_for_syndication(s): @@ -99,6 +93,7 @@ def post_to_twitter(obj, ctype): except: status = t.update_status(status=status) + def post_photo_to_flickr(photo): flickr = flickrapi.FlickrAPI(settings.FLICKR_API_KEY, settings.FLICKR_API_SECRET) flickr.auth_url(perms='write') @@ -112,20 +107,10 @@ def post_photo_to_flickr(photo): pass -# Hide deprecation warnings. The facebook module isn't that up-to-date (facebook.GraphAPIError). -warnings.filterwarnings('ignore', category=DeprecationWarning) - - -# Parameters of your app and the id of the profile you want to mess with. - - -# Trying to get an access token. Very awkward. - -def post_photo_to_facebook(obj, ctype): - token = facebook.GraphAPI().get_app_access_token(settings.FACEBOOK_APP_ID, settings.FACEBOOK_APP_SECRET) - graph = facebook.GraphAPI(access_token=token, version='2.2') - - # Try to post something on the wall. +def post_to_facebook(obj, ctype): + from syndication.models import FBOAuthToken + token = FBOAuthToken.objects.latest() + graph = facebook.GraphAPI(access_token=token.long_token, version='2.2') if ctype == "lux image": p = open(obj.get_image_path_by_size("2280"), 'rb') if obj.caption: |