#NEWLINE# def any( self , provider_name ) : #NEWLINE# #INDENT# session = gae . Webapp2Session ( self , secret = 'abc' ) #NEWLINE# result = authomatic . login ( Webapp2Adapter ( self ) , provider_name , session = session , session_saver = session . save ) #NEWLINE# if result : #NEWLINE# #INDENT# self . response . write ( '<a href="..">Home</a>' ) #NEWLINE# if result . error : #NEWLINE# #INDENT# self . response . write ( '<h2>Damn that error: {}</h2>' . format ( result . error . message ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if result . user : #NEWLINE# #INDENT# result . user . update ( ) #NEWLINE# self . response . write ( '<h1>Hi {}</h1>' . format ( result . user . name ) ) #NEWLINE# self . response . write ( '<h2>Your id is: {}</h2>' . format ( result . user . id ) ) #NEWLINE# self . response . write ( '<h2>Your email is: {}</h2>' . format ( result . user . email ) ) #NEWLINE# if result . user . credentials : #NEWLINE# #INDENT# if ( result . provider . name == 'fb' ) : #NEWLINE# #INDENT# self . response . write ( 'Your are logged in with Facebook,<br />' ) #NEWLINE# url = 'https://graph.facebook.com/{}?fields=feed.limit(5).fields(message)' #NEWLINE# url = url . format ( result . user . id ) #NEWLINE# response = result . provider . access ( url ) #NEWLINE# if ( response . status == 200 ) : #NEWLINE# #INDENT# statuses = response . data . get ( 'feed' ) . get ( 'data' ) #NEWLINE# error = response . data . get ( 'error' ) #NEWLINE# if error : #NEWLINE# #INDENT# self . response . write ( 'Damn that error: {}!' . format ( error ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if statuses : #NEWLINE# #INDENT# self . response . write ( 'and these are your 5 most recent statuses:<br /><br />' ) #NEWLINE# for message in statuses : #NEWLINE# #INDENT# text = message . get ( 'message' ) #NEWLINE# date = message . get ( 'created_time' ) #NEWLINE# self . response . write ( '<h3>{}</h3>' . format ( text ) ) #NEWLINE# self . response . write ( 'Posted on: {}<br /><br />' . format ( date ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . response . write ( 'Damn that unknown error!<br />' ) #NEWLINE# self . response . write ( 'Status: {}' . format ( response . status ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( result . provider . name == 'tw' ) : #NEWLINE# #INDENT# self . response . write ( 'Your are logged in with Twitter,<br />' ) #NEWLINE# url = 'https://api.twitter.com/1.1/statuses/user_timeline.json' #NEWLINE# response = result . provider . access ( url , { #NEWLINE# #INDENT# 'count' : 5 , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( response . status == 200 ) : #NEWLINE# #INDENT# if ( type ( response . data ) is list ) : #NEWLINE# #INDENT# self . response . write ( 'and these are your 5 most recent tweets:' ) #NEWLINE# for tweet in response . data : #NEWLINE# #INDENT# text = tweet . get ( 'text' ) #NEWLINE# date = tweet . get ( 'created_at' ) #NEWLINE# self . response . write ( '<h3>{}</h3>' . format ( text ) ) #NEWLINE# self . response . write ( 'Tweeted on: {}' . format ( date ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if response . data . get ( 'errors' ) : #NEWLINE# #INDENT# self . response . write ( 'Damn that error: {}!' . format ( response . data . get ( 'errors' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . response . write ( 'Damn that unknown error!<br />' ) #NEWLINE# self . response . write ( 'Status: {}' . format ( response . status ) )