예제 #1
0
def sina_login_suc(request):
    
    code = request.GET['code']
    client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL)
    r = client.request_access_token(code)
    access_token = r.access_token
    expires_in = r.expires_in
    client.set_access_token(access_token, expires_in)
    uid = str(client.get.account__get_uid()["uid"])
    userProfile = client.users__show(uid=uid)
    loginRedis.set("user_"+uid,userProfile)
    request.session['uid'] = uid
    request.session['screen_name'] = userProfile['screen_name']
    loginRedis.hset('token_'+uid,"access_token",access_token)
    loginRedis.hset('token_'+uid,"expires_in",expires_in)
    if PRedis.exists('ponit_'+uid) == False:
        PRedis.hset('ponit_'+uid,'current_point',10)
        PRedis.hset('ponit_'+uid,'time',1)
    if PHRedis.exists('ph_'+uid) == False:
       dt = {"current_point":10,
            "previous_point":0,
            "change_point":"+10",
            "change_time":time.strftime("%Y-%m-%d %H:%M:%S"),
            "change_reason":"用户新注册", }
       PHRedis.lpush('ph_'+uid,dt)
    
    if PRedis.exists('ponit_gg_'+uid) == False:
        PRedis.hset('ponit_gg_'+uid,'current_point',1)
        PRedis.hset('ponit_gg_'+uid,'time',1)
    if PHRedis.exists('ph_gg_'+uid) == False:
       dt = {"current_point":1,
            "previous_point":0,
            "change_point":"+1",
            "change_time":time.strftime("%Y-%m-%d %H:%M:%S"),
            "change_reason":"用户新注册", }
       PHRedis.lpush('ph_gg_'+uid,dt)
    return HttpResponseRedirect("/oauth/start")
예제 #2
0
def use_sina_login(request):
    
    client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL)
    
    return HttpResponseRedirect(client.get_authorize_url())