From 9bc9b213fb5849b20c965b7bd6695b5796ba19ae Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 31 Mar 2016 11:09:08 -0400 Subject: added support for Facebook Instant Articles to syndication app --- app/syndication/syndicators.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'app/syndication/syndicators.py') diff --git a/app/syndication/syndicators.py b/app/syndication/syndicators.py index de157af..82b9564 100644 --- a/app/syndication/syndicators.py +++ b/app/syndication/syndicators.py @@ -1,7 +1,8 @@ from django.conf import settings +from django.test.client import Client from bs4 import BeautifulSoup -from medium import Client +from medium import Client as MediumClient def absolute_urls_for_syndication(s): @@ -9,11 +10,11 @@ def absolute_urls_for_syndication(s): for a in soup.find_all('a'): if a['href'][:1] == "/": a['href'] = "https://luxagraf.net%s" % a['href'] - print(soup) + return soup def post_to_medium(item): - client = Client(application_id=settings.MEDIUM_CLIENT_ID, application_secret=settings.MEDIUM_CLIENT_SECRET) + client = MediumClient(application_id=settings.MEDIUM_CLIENT_ID, application_secret=settings.MEDIUM_CLIENT_SECRET) client.access_token = settings.MEDIUM_INT_TOKEN user = client.get_current_user() head = '

This was originally posted on my own site.

' % item.get_absolute_url() @@ -29,3 +30,11 @@ def post_to_medium(item): license="all-rights-reserved" ) return post["url"] + + +def build_facebook_feed(item): + c = Client() + response = c.get('/iafeed.xml', HTTP_HOST='127.0.0.1') + f = open("%siafeed.xml" % settings.FLATFILES_ROOT, 'wb') + f.write(response.content) + f.close() -- cgit v1.2.3-70-g09d2