示例#1
0
def index(name="index", *args, **kawrgs):
    if request.is_xhr:
        return "", 400

    if g.user:
        # try:
        graph = GraphAPI(g.user['access_token'])
        args = {'fields': 'birthday, name, email'}
        facebook_friends = graph.get_object('me/friends', **args)

        user = UserActions.find_by_id(g.user['id'])

        for facebook_friend in facebook_friends['data']:
            friend = UserActions.new(facebook_friend)
            FriendRelationshipActions.create(user, friend)

        relations = FriendRelationshipActions.find_by_user(user)

        return render_template("index.html",
                               app_id=app.config["FB_APP_ID"],
                               user=user,
                               relations=relations)
    # except Exception:
    #     return redirect(url_for('logout'))

    return render_template("login.html", app_id=app.config["FB_APP_ID"])
示例#2
0
def get_friends(user):
    graph = GraphAPI(user.access_token)
    args = {'fields': 'birthday, name, email'}
    facebook_friends = graph.get_object('me/friends', **args)

    for facebook_friend in facebook_friends['data']:
        friend = UserActions.new(facebook_friend)
        FriendRelationshipActions.create(user, friend)
        get_friend_post(facebook_friend, user.access_token)
        get_friend_event(facebook_friend, user.access_token)
    pass
示例#3
0
def get_friends(user):
    graph = GraphAPI(user.access_token)
    args = {'fields' : 'birthday, name, email'}
    facebook_friends = graph.get_object('me/friends', **args)

    for facebook_friend in facebook_friends['data']:
        friend = UserActions.new(facebook_friend)
        FriendRelationshipActions.create(user, friend)
        get_friend_post(facebook_friend, user.access_token)
        get_friend_event(facebook_friend, user.access_token)
    pass
示例#4
0
def index(name="index", *args, **kawrgs):
    if request.is_xhr:
        return "", 400

    if g.user:
        # try:
            graph = GraphAPI(g.user['access_token'])
            args = {'fields': 'birthday, name, email'}
            facebook_friends = graph.get_object('me/friends', **args);

            user = UserActions.find_by_id(g.user['id'])

            for facebook_friend in facebook_friends['data']:
                friend = UserActions.new(facebook_friend)
                FriendRelationshipActions.create(user, friend)

            relations = FriendRelationshipActions.find_by_user(user)

            return render_template("index.html", app_id=app.config["FB_APP_ID"], user=user, relations=relations)
        # except Exception:
        #     return redirect(url_for('logout'))

    return render_template("login.html", app_id=app.config["FB_APP_ID"])