Skip to content

Commit

Permalink
Merge pull request #122 from mitmedialab/dsjen/robust-fb-url
Browse files Browse the repository at this point in the history
Construct Facebook URL via urljoin
  • Loading branch information
dsjen authored Feb 8, 2019
2 parents 8a23a57 + e73150d commit babff48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/app/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export const DELETE_USER_REQUEST = 'DELETE_USER_REQUEST';
export const DELETE_USER_SUCCESS = 'DELETE_USER_SUCCESS';
export const DELETE_USER_FAILURE = 'DELETE_USER_FAILURE';

export const VERSION = 'v1.12.6';
export const VERSION = 'v1.12.7';

export const API_URL = ''; // process.env.NODE_ENV === 'production' ? '': 'http://localhost:5000/'
6 changes: 4 additions & 2 deletions server/scripts/queue_latest_news_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import csv
from datetime import datetime, timedelta
from urlparse import urljoin
import requests
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
Expand Down Expand Up @@ -56,7 +57,7 @@ def queue_lastest_news_posts(db_session):
MAX_POST = 3
date_N_days_ago = datetime.now() - timedelta(days=N)
since_date = date_N_days_ago.strftime('%Y-%m-%d')
facebook_payload = {
facebook_query = {
'fields': ','.join(tasks.FACEBOOK_POSTS_FIELDS),
'access_token': '{}|{}'.format(config.FACEBOOK_APP_ID, config.FACEBOOK_APP_SECRET),
'since': since_date,
Expand Down Expand Up @@ -88,7 +89,8 @@ def queue_lastest_news_posts(db_session):
logger.info(" {}".format(row['Facebook Page']))
# get facebook feed
data = {'id': row['Facebook Page'].replace('https://www.facebook.com/', '')}
r = requests.get(tasks.FACEBOOK_URL + data['id'] + 'feed', facebook_payload)
url = urljoin(tasks.FACEBOOK_URL, data['id'], 'feed')
r = requests.get(url, facebook_query)
result = r.json()
if 'error' in result:
logger.warn(" unable to fetch FB data - error {} - {}".format(
Expand Down

0 comments on commit babff48

Please sign in to comment.