Beispiel #1
0
def TwitterUnlinkHandler(request):
    if request.method == "GET":
        member = CheckAuth(request)
        if member:
            memcache.delete("Member_" + str(member.num))
            member = GetKindByNum("Member", member.num)
            member.twitter_oauth = 0
            member.twitter_oauth_key = ""
            member.twitter_oauth_secret = ""
            member.twitter_sync = 0
            member.save()
            memcache.set("Member_" + str(member.num), member, 86400)
            return HttpResponseRedirect("/settings")
        else:
            return HttpResponseRedirect("/signin")
Beispiel #2
0
def TwitterUnlinkHandler(request):
    if request.method == 'GET':
        member = CheckAuth(request)
        if member:
            memcache.delete('Member_' + str(member.num))
            member = GetKindByNum('Member', member.num)
            member.twitter_oauth = 0
            member.twitter_oauth_key = ''
            member.twitter_oauth_secret = ''
            member.twitter_sync = 0
            member.save()
            memcache.set('Member_' + str(member.num), member, 86400)
            return HttpResponseRedirect('/settings')
        else:
            return HttpResponseRedirect('/signin')
Beispiel #3
0
def TwitterCallbackHandler(request):
    if request.method == "GET":
        session = request.session
        member = CheckAuth(request)
        host = request.META["HTTP_HOST"]
        if host == "localhost:8000" or host == "127.0.0.1:8000":
            # Local debugging logic
            if member:
                request_token = session["request_token"]
                twitter = OAuthApi(config.twitter_consumer_key, config.twitter_consumer_secret, request_token)
                access_token = twitter.getAccessToken()
                twitter = OAuthApi(config.twitter_consumer_key, config.twitter_consumer_secret, access_token)
                user = twitter.GetUserInfo()
                memcache.delete("Member_" + str(member.num))
                member = Member.objects.filter(num=member.num)[0]
                member.twitter_oauth = 1
                member.twitter_oauth_key = access_token.key
                member.twitter_oauth_secret = access_token.secret
                member.twitter_oauth_string = access_token.to_string()
                member.twitter_sync = 0
                member.twitter_id = user.id
                member.twitter_name = user.name
                member.twitter_screen_name = user.screen_name
                member.twitter_location = user.location
                member.twitter_description = user.description
                member.twitter_profile_image_url = user.profile_image_url
                member.twitter_url = user.url
                member.twitter_statuses_count = user.statuses_count
                member.twitter_followers_count = user.followers_count
                member.twitter_friends_count = user.friends_count
                member.twitter_favourites_count = user.favourites_count
                member.save()
                memcache.set("Member_" + str(member.num), member, 86400)
                return HttpResponseRedirect("/settings")
            else:
                return HttpResponseRedirect("/signin")
        else:
            # Remote production logic
            if member and "request_token" in session:
                request_token = session["request_token"]
                twitter = OAuthApi(config.twitter_consumer_key, config.twitter_consumer_secret, request_token)
                access_token = twitter.getAccessToken()
                twitter = OAuthApi(config.twitter_consumer_key, config.twitter_consumer_secret, access_token)
                user = twitter.GetUserInfo()
                memcache.delete("Member_" + str(member.num))
                member = Member.objects.filter(num=member.num)[0]
                member.twitter_oauth = 1
                member.twitter_oauth_key = access_token.key
                member.twitter_oauth_secret = access_token.secret
                member.twitter_oauth_string = access_token.to_string()
                member.twitter_sync = 0
                member.twitter_id = user.id
                member.twitter_name = user.name
                member.twitter_screen_name = user.screen_name
                if not user.location or len(user.location) == 0:
                    member.twitter_location = ""
                else:
                    member.twitter_location = user.location
                if not user.description or len(user.description) == 0:
                    member.twitter_description = ""
                else:
                    member.twitter_description = user.description
                member.twitter_profile_image_url = user.profile_image_url
                if not user.url or len(user.url) == 0:
                    member.twitter_url = ""
                else:
                    member.twitter_url = user.url
                member.twitter_statuses_count = user.statuses_count
                member.twitter_followers_count = user.followers_count
                member.twitter_friends_count = user.friends_count
                member.twitter_favourites_count = user.favourites_count
                member.save()
                memcache.set("Member_" + str(member.num), member, 86400)
                return HttpResponseRedirect("/settings")
            else:
                oauth_token = request.GET["oauth_token"]
                if host == "www.woosuko.com":
                    return HttpResponseRedirect("http://www.woosuko.com/twitter-oauth?oauth_token=" + oauth_token)
                else:
                    return HttpResponseRedirect("http://localhost:8000/twitter-oauth?oauth_token=" + oauth_token)
Beispiel #4
0
def TwitterCallbackHandler(request):
    if request.method == 'GET':
        session = request.session
        member = CheckAuth(request)
        host = request.META['HTTP_HOST']
        if host == 'localhost:8000' or host == '127.0.0.1:8000':
            # Local debugging logic
            if member:
                request_token = session['request_token']
                twitter = OAuthApi(config.twitter_consumer_key,
                                   config.twitter_consumer_secret,
                                   request_token)
                access_token = twitter.getAccessToken()
                twitter = OAuthApi(config.twitter_consumer_key,
                                   config.twitter_consumer_secret,
                                   access_token)
                user = twitter.GetUserInfo()
                memcache.delete('Member_' + str(member.num))
                member = Member.objects.filter(num=member.num)[0]
                member.twitter_oauth = 1
                member.twitter_oauth_key = access_token.key
                member.twitter_oauth_secret = access_token.secret
                member.twitter_oauth_string = access_token.to_string()
                member.twitter_sync = 0
                member.twitter_id = user.id
                member.twitter_name = user.name
                member.twitter_screen_name = user.screen_name
                member.twitter_location = user.location
                member.twitter_description = user.description
                member.twitter_profile_image_url = user.profile_image_url
                member.twitter_url = user.url
                member.twitter_statuses_count = user.statuses_count
                member.twitter_followers_count = user.followers_count
                member.twitter_friends_count = user.friends_count
                member.twitter_favourites_count = user.favourites_count
                member.save()
                memcache.set('Member_' + str(member.num), member, 86400)
                return HttpResponseRedirect('/settings')
            else:
                return HttpResponseRedirect('/signin')
        else:
            # Remote production logic
            if member and 'request_token' in session:
                request_token = session['request_token']
                twitter = OAuthApi(config.twitter_consumer_key,
                                   config.twitter_consumer_secret,
                                   request_token)
                access_token = twitter.getAccessToken()
                twitter = OAuthApi(config.twitter_consumer_key,
                                   config.twitter_consumer_secret,
                                   access_token)
                user = twitter.GetUserInfo()
                memcache.delete('Member_' + str(member.num))
                member = Member.objects.filter(num=member.num)[0]
                member.twitter_oauth = 1
                member.twitter_oauth_key = access_token.key
                member.twitter_oauth_secret = access_token.secret
                member.twitter_oauth_string = access_token.to_string()
                member.twitter_sync = 0
                member.twitter_id = user.id
                member.twitter_name = user.name
                member.twitter_screen_name = user.screen_name
                if not user.location or len(user.location) == 0:
                    member.twitter_location = ''
                else:
                    member.twitter_location = user.location
                if not user.description or len(user.description) == 0:
                    member.twitter_description = ''
                else:
                    member.twitter_description = user.description
                member.twitter_profile_image_url = user.profile_image_url
                if not user.url or len(user.url) == 0:
                    member.twitter_url = ''
                else:
                    member.twitter_url = user.url
                member.twitter_statuses_count = user.statuses_count
                member.twitter_followers_count = user.followers_count
                member.twitter_friends_count = user.friends_count
                member.twitter_favourites_count = user.favourites_count
                member.save()
                memcache.set('Member_' + str(member.num), member, 86400)
                return HttpResponseRedirect('/settings')
            else:
                oauth_token = request.GET['oauth_token']
                if host == 'www.woosuko.com':
                    return HttpResponseRedirect(
                        'http://www.woosuko.com/twitter-oauth?oauth_token=' +
                        oauth_token)
                else:
                    return HttpResponseRedirect(
                        'http://localhost:8000/twitter-oauth?oauth_token=' +
                        oauth_token)