Skip to content

Commit

Permalink
Merge pull request #4 from eventbrite/log-picture-errors
Browse files Browse the repository at this point in the history
Add error logging for picture post
  • Loading branch information
tophevb committed Jun 30, 2015
2 parents b86cd37 + fd2884c commit c9f9d13
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions facebook/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,17 @@ def put_event(self, id=None, page_id=None, **data):
post_args = {}
post_args['access_token'] = self.access_token
post_args['cover_url'] = data['picture']
# Silently ignore errors when uploading logos so it doesn't block
# event publishing. Apparently v2.4 of the Facebook API will allow
# us to publish the event with the picture in one POST instead of
# this 2-step dance.
requests.post(url, data=post_args)

return response
picture_response = requests.post(url, data=post_args)
# If there's an error, return the message to the calling code so we
# can log it. Not raising a GraphAPIError here because we want the
# event to publish even if there is an error in uploading the
# picture.
if picture_response.status_code != 200:
json_response = picture_response.json()
error_message = json_response.get('error').get('message')
return response, error_message

return response, None

def put_comment(self, object_id, message):
"""Writes the given comment on the given post."""
Expand Down

0 comments on commit c9f9d13

Please sign in to comment.