Example #1
0
def index():
    print get_home()
    if request.args.get('code', None):
        access_token = fbapi_auth(request.args.get('code'))[0]

        me = fb_call('me', args={'access_token': access_token})
        app = fb_call(FBAPI_APP_ID, args={'access_token': access_token})
        likes = fb_call('me/likes',
                        args={'access_token': access_token, 'limit': 4})
        friends = fb_call('me/friends',
                          args={'access_token': access_token, 'limit': 5})
        photos = fb_call('me/photos',
                         args={'access_token': access_token, 'limit': 16})
	statuses = fb_call('me/statuses',
			 args={'access_token': access_token, 'limit': 100})
	
	(first_date, percent, months, most_used_profanities, timeline) = generate_data(statuses['data'])

        redir = get_home() + 'close/'
        POST_TO_WALL = ("https://www.facebook.com/dialog/feed?redirect_uri=%s&"
                        "display=popup&app_id=%s" % (redir, FBAPI_APP_ID))

        app_friends = fql(
            "SELECT uid, name, is_app_user, pic_square "
            "FROM user "
            "WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND "
            "  is_app_user = 1", access_token)

        SEND_TO = ('https://www.facebook.com/dialog/send?'
                   'redirect_uri=%s&display=popup&app_id=%s&link=%s'
                   % (redir, FBAPI_APP_ID, get_home()))

        return render_template(
            'prof.html', appId=FBAPI_APP_ID, token=access_token, likes=likes,
            friends=friends, photos=photos, app_friends=app_friends, app=app,
            statuses=statuses, percent=percent, first_date=first_date, months=months, most_used_profanities=most_used_profanities, timeline=timeline,
            me=me, POST_TO_WALL=POST_TO_WALL, SEND_TO=SEND_TO)
    else:
        print oauth_login_url(next_url=get_home())
        return redirect(oauth_login_url(next_url=get_home()))
Example #2
0
def index():
    #print get_home()
    if request.args.get('code', None):
        access_token = fbapi_auth(request.args.get('code'))[0]

        #GRAPH API EXAMPLE:
        me = fb_call('me', args={'access_token': access_token})

        print 'RUNNING APPLICATION FOR USER: '******'name']
        
	statuses = fb_call('me/statuses',
			 args={'access_token': access_token, 'limit': 0})
	
	(first_date, percent, months, most_used_profanities, timeline) = generate_data(statuses['data'])

        redir = get_home() + 'close/'
        POST_TO_WALL = ("https://www.facebook.com/dialog/feed?redirect_uri=%s&"
                        "display=popup&app_id=%s" % (redir, FBAPI_APP_ID))

        app_friends = fql(
            "SELECT uid, name, is_app_user, pic_square "
            "FROM user "
            "WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND "
            "  is_app_user = 1", access_token)

        SEND_TO = ('https://www.facebook.com/dialog/send?'
                   'redirect_uri=%s&display=popup&app_id=%s&link=%s'
                   % (redir, FBAPI_APP_ID, get_home()))

        print 'SUCCESSFULLY RAN APPLICATION FOR USER: '******'name']

        return render_template(
            'index.html', appId=FBAPI_APP_ID, token=access_token,
            statuses=statuses, percent=percent, first_date=first_date, months=months, most_used_profanities=most_used_profanities, timeline=timeline,
            )
    else:
        #print oauth_login_url(next_url=get_home())
        return redirect(oauth_login_url(next_url=get_home()))