Ciao a tutti!
Uso un app in Python su smartphone che scarica i dati dei contatti da facebook (compleanni etc) e aggiorna rubrica e calendario coi compleanni etc.
Purtroppo lo sviluppatore ha smesso di aggiornarla e ora non si collega più a facebook.
Probabilmente perchè è cambiato il metodo di login oauth, o l'api?
Ho dato un occhiata al codice qui
https://garage.maemo.org/plugins/ggit/browse.php/?p=hermes;a=tree;f=package/src;h=12cc5b361859667d91edb6e07d4eea9051f44a99;hb=HEAD ma essendo un niubbo, cercavo un esperto che potesse individuare il fix corretto.
Comunque ho letto la doc di facebook
https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/Potrebbe bastare modificare il file oauth2.py, con il redirect_uri consigliato da facebook?
[codice=python]def authorise(self, authorise_url, access_token_url, args = None):
'''Open a browser window to allow the user to log in and
authorise this client.'''
redirect_uri = '
http://localhost:3435/success'
webbrowser.open_new('%s?client_id=%s&redirect_uri=%s&%s' % (authorise_url, self._client_id, redirect_uri, args and urllib.urlencode(args) or ''))
handler = OAuthCodeHandler()
code = handler.run()
result = urllib2.urlopen('%s?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s' % (access_token_url, self._client_id, redirect_uri, self._client_secret, code)).read()
params = cgi.parse_qs(result)
if 'access_token' in params:
self._access_token = params['access_token'][0]
else:
print result, params
raise Exception('Unable to retrieve access_token from Facebook')[/codice]
cioè redirect_uri = '
http://localhost:3435/success' -> redirect_uri = '
https://www.facebook.com/connect/login_success.html'
va cambiata anche questa classe?
[codice=python]class OAuthCodeHandler(HTTPServer):
"""Handles the response from an OAuth2 handler and allows the
retrieval of the code."""
# -----------------------------------------------------------------------
def __init__(self, success_response = '<h1>Success</h1><p>Please now close this window.</p>',
failure_response = '<h1>Failed</h1><p>%s</p>'):
'''Create a new handler, with optional overrides of the
success and failure response messages.'''
HTTPServer.__init__(self, ('127.0.0.1', 3435), OAuthHttpRequestHandler)
self._success_response = success_response
self._failure_response = failure_response
self._code = None
[/codice]
l'access_token dovrebbe essere preso da
https://www.facebook.com/connect/login_success.html# access_token=<ACCESS_TOKEN>
Consigli?