maraujo / pySocialWatcher

Social Watcher on Facebook Marketing API
MIT License
109 stars 49 forks source link

How to handle "Sorry, something went wrong." #16

Open peterampazzo opened 5 years ago

peterampazzo commented 5 years ago

Hello, I noticed that the process fail when the Facebook API responds with a new error. It's not a json, but a html page.

The source of the web page is always the same: <!DOCTYPE html>\n<html lang="en" id="facebook">\n <head>\n <title>Facebook | Error</title>\n <meta charset="utf-8">\n <meta http-equiv="cache-control" content="no-cache">\n <meta http-equiv="cache-control" content="no-store">\n <meta http-equiv="cache-control" content="max-age=0">\n <meta http-equiv="expires" content="-1">\n <meta http-equiv="pragma" content="no-cache">\n <meta name="robots" content="noindex,nofollow">\n <style>\n html, body {\n color: #141823;\n background-color: #e9eaed;\n font-family: Helvetica, Lucida Grande, Arial,\n Tahoma, Verdana, sans-serif;\n margin: 0;\n padding: 0;\n text-align: center;\n }\n\n #header {\n height: 30px;\n padding-bottom: 10px;\n padding-top: 10px;\n text-align: center;\n }\n\n #icon {\n width: 30px;\n }\n\n h1 {\n font-size: 18px;\n }\n\n p {\n font-size: 13px;\n }\n\n #footer {\n border-top: 1px solid #ddd;\n color: #9197a3;\n font-size: 12px;\n padding: 5px 8px 6px 0;\n }\n </style>\n </head>\n <body>\n <div id="header">\n <a href="//www.facebook.com/">\n <img id="icon" src="//static.facebook.com/images/logos/facebook_2x.png" />\n </a>\n </div>\n <div id="core">\n <h1 id="sorry">Sorry, something went wrong.</h1>\n <p id="promise">\n We\'re working on it and we\'ll get it fixed as soon as we can.\n </p>\n <p id="back-link">\n <a id="back" href="//www.facebook.com/">Go Back</a>\n </p>\n <div id="footer">\n Facebook\n <span id="copyright">\n &copy; 2018\n </span>\n <span id="help-link">\n &#183;\n <a id="help" href="//www.facebook.com/help/">Help Center</a>\n </span>\n </div>\n </div>\n <script>\n document.getElementById(\'back\').onclick = function() {\n if (history.length > 1) {\n history.back();\n return false;\n }\n };\n\n // Adjust the display based on the window size\n if (window.innerHeight < 80 || window.innerWidth < 80) {\n // Blank if window is too small\n document.body.style.display = \'none\';\n };\n if (window.innerWidth < 200 || window.innerHeight < 150) {\n document.getElementById(\'back-link\').style.display = \'none\';\n document.getElementById(\'help-link\').style.display = \'none\';\n };\n if (window.innerWidth < 200) {\n document.getElementById(\'sorry\').style.fontSize = \'16px\';\n };\n if (window.innerWidth < 150) {\n document.getElementById(\'promise\').style.display = \'none\';\n };\n if (window.innerHeight < 150) {\n document.getElementById(\'sorry\').style.margin = \'4px 0 0 0\';\n document.getElementById(\'sorry\').style.fontSize = \'14px\';\n document.getElementById(\'promise\').style.display = \'none\';\n };\n </script>\n </body>\n</html>\n

If I'm not wrong, at the moment the error is handle by the function handle_send_request_error() in utils.py. As this seems to be a temporary problem on Facebook, which can be the best way to handle it and trying to restore the process? By calling perform_collection_data_on_facebook()?

Thanks!

maraujo commented 5 years ago

Dear Rampazzo, This usually happens when an internal error occurs in Facebook system, they should always return a json output, even if the syntax is incorrect.

Matheus Araújo M.Sc in Computer Science at UFMG Pursuing Ph.D. at the University of Minnesota.

On Thu, Jan 10, 2019 at 3:02 PM Pietro Rampazzo notifications@github.com wrote:

Hello, I noticed that the process fail when the Facebook API responds with a new error. It's not a json, but a html page.

The source of the web page is always the same: ` \n\n \n Facebook | Error\n \n \n \n \n \n \n \n \n \n

\n \n \n \n <//www.facebook.com/>\n \n \n Sorry, something went wrong.\n

\n We\'re working on it and we\'ll get it fixed as soon as we can.\n \n

\n Go Back <//www.facebook.com/>\n \n \n Facebook\n \n © 2018\n \n \n ·\n Help Center <//www.facebook.com/help/>\n \n \n \n \n \n\n

`

If I'm not wrong, at the moment the error is handle by the function handle_send_request_error() in utils.py. As this seems to be a temporary problem on Facebook, which can be the best way to handle it and trying to restore the process? By calling perform_collection_data_on_facebook()?

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/maraujo/pySocialWatcher/issues/16, or mute the thread https://github.com/notifications/unsubscribe-auth/AH2sodF4njp0igJI2Zk__l8DqB6xEdySks5vB6pLgaJpZM4Z6Tyr .