Exemplo n.º 1
0
def repost(request):
    weibo_id = request.POST.get("weibo_id", "")
    content = request.POST.get("content", "")
    client = return_client()
    client.statuses.repost.post(id=weibo_id, status=content)
    reback = "access_token=" + client.access_token + "&nickname=" + client.nickname
    return HttpResponse(reback)
Exemplo n.º 2
0
def getcomments(request, weibo_id, page=1):
    client = return_client()
    #print weibo_id
    comments = client.comments.show.get(id=weibo_id, page=page)
    comments_list = comments.comments
    #json模块提供了用于将字典转换为json的方法
    return HttpResponse(json.dumps(comments_list))
Exemplo n.º 3
0
def getcomments(request,weibo_id,page=1):
    client = return_client()
    #print weibo_id
    comments = client.comments.show.get(id=weibo_id,page = page)
    comments_list = comments.comments
    #json模块提供了用于将字典转换为json的方法
    return  HttpResponse(json.dumps(comments_list))
Exemplo n.º 4
0
def repost(request):
    weibo_id = request.POST.get("weibo_id","")
    content = request.POST.get("content","")
    client = return_client()
    client.statuses.repost.post(id=weibo_id,status=content)
    reback = "access_token="+client.access_token+"&nickname="+client.nickname
    return HttpResponse(reback)
Exemplo n.º 5
0
def get_access_token(request):
    #print request.GET['code']
    conn = pymongo.Connection("localhost")
    db = conn.myweibo
    access = db.access
    client = return_client()
    r = client.request_access_token(request.GET['code'])
    access_token = r.access_token  # 新浪返回的token,类似abc123xyz456
    expires_in = r.expires_in  # token过期的UNIX时间:http://zh.wikipedia.org/wiki/UNIX%E6%97%B6%E9%97%B4
    print '=> the new access_token is : %s' % access_token
    print 'access_token expires_in: ', expires_in
    #dump_tokens(access_token)
    client.set_access_token(access_token, expires_in)
    data = client.users.show.get(uid=r.get('uid', None))
    nickname = data.screen_name
    id_pic = data.profile_image_url
    client.access_token = access_token
    client.nickname = nickname
    access.insert({
        "nickname": nickname,
        "id_pic": id_pic,
        "access_token": access_token
    })
    conn.close()
    return HttpResponseRedirect("/access_login/?access_token=" + access_token +
                                "&nickname=" + nickname)
Exemplo n.º 6
0
def post_comment(request):
    weibo_id = request.POST.get("wid", "")
    comm_id = request.POST.get("cid", "")
    comms = request.POST.get("data", "")
    client = return_client()
    client.comments.reply.post(id=weibo_id, cid=comm_id, comment=comms)
    comments = client.comments.show.get(id=weibo_id, page=1)
    comments_list = comments.comments
    return HttpResponse(json.dumps(comments_list))
Exemplo n.º 7
0
def getweibo(request,page=1):
    if int(page) == 0 :
        page = 1
    client = return_client()
    form = weibodata()
    data = client.statuses.home_timeline.get(page=page,count=20)
    home_list = data.statuses
    return render_to_response("home_timeline.html",{"home_list":home_list,"page":page,"form":form,
                                                    "access_token":client.access_token,
                                                    "nickname":client.nickname})
Exemplo n.º 8
0
def login(request,page=1):
    flag = get_client()
    client = return_client()
    if flag:
        data = client.statuses.home_timeline.get(page=page,count=20)
        home_list = data.statuses
        form = weibodata()
        return render_to_response("home_timeline.html",{"home_list":home_list,"page":page,"form":form})
    #print type(client)
    return render_to_response("index.html")
Exemplo n.º 9
0
def post_comment(request):
    weibo_id = request.POST.get("wid","")
    comm_id = request.POST.get("cid","")
    comms =  request.POST.get("data","")
    client = return_client()
    client.comments.reply.post(id=weibo_id,cid=comm_id,comment=comms)
    comments = client.comments.show.get(id=weibo_id,page = 1)
    comments_list = comments.comments
    return HttpResponse(json.dumps(comments_list));
    
        
    
Exemplo n.º 10
0
def post_weibo(request):
    content =  request.POST["content"]
    weibo_img = request.FILES.get("weibo_img","")
    client =  return_client()
    #print content
    #print weibo_img
    if weibo_img:
        client.statuses.upload.post(status=content, pic=weibo_img)
    else:
        client.statuses.update.post(status = content)
    #time.sleep(1)
    return HttpResponseRedirect("/access_login/?access_token="+client.access_token+"&nickname="+client.nickname)
Exemplo n.º 11
0
def access_login(request,page=1):
    access_token= request.GET.get("access_token","")
    nickname= request.GET.get("nickname","")
    flag = get_client(access_token,nickname)
    client = return_client()
    if flag:
        data = client.statuses.home_timeline.get(page=page,count=20)
        home_list = data.statuses
        form = weibodata()
        return render_to_response("home_timeline.html",{"home_list":home_list,"page":page,
                                                        "form":form,"nickname":nickname,
                                                        "access_token":access_token})
Exemplo n.º 12
0
def post_weibo(request):
    content = request.POST["content"]
    weibo_img = request.FILES.get("weibo_img", "")
    client = return_client()
    #print content
    #print weibo_img
    if weibo_img:
        client.statuses.upload.post(status=content, pic=weibo_img)
    else:
        client.statuses.update.post(status=content)
    #time.sleep(1)
    return HttpResponseRedirect("/access_login/?access_token=" +
                                client.access_token + "&nickname=" +
                                client.nickname)
Exemplo n.º 13
0
def login(request, page=1):
    flag = get_client()
    client = return_client()
    if flag:
        data = client.statuses.home_timeline.get(page=page, count=20)
        home_list = data.statuses
        form = weibodata()
        return render_to_response("home_timeline.html", {
            "home_list": home_list,
            "page": page,
            "form": form
        })
    #print type(client)
    return render_to_response("index.html")
Exemplo n.º 14
0
def getweibo(request, page=1):
    if int(page) == 0:
        page = 1
    client = return_client()
    form = weibodata()
    data = client.statuses.home_timeline.get(page=page, count=20)
    home_list = data.statuses
    return render_to_response(
        "home_timeline.html", {
            "home_list": home_list,
            "page": page,
            "form": form,
            "access_token": client.access_token,
            "nickname": client.nickname
        })
Exemplo n.º 15
0
def access_login(request, page=1):
    access_token = request.GET.get("access_token", "")
    nickname = request.GET.get("nickname", "")
    flag = get_client(access_token, nickname)
    client = return_client()
    if flag:
        data = client.statuses.home_timeline.get(page=page, count=20)
        home_list = data.statuses
        form = weibodata()
        return render_to_response(
            "home_timeline.html", {
                "home_list": home_list,
                "page": page,
                "form": form,
                "nickname": nickname,
                "access_token": access_token
            })
Exemplo n.º 16
0
def get_access_token(request):
    #print request.GET['code']
    conn = pymongo.Connection("localhost")
    db = conn.myweibo
    access = db.access
    client = return_client()
    r = client.request_access_token(request.GET['code'])
    access_token = r.access_token   # 新浪返回的token,类似abc123xyz456
    expires_in = r.expires_in   # token过期的UNIX时间:http://zh.wikipedia.org/wiki/UNIX%E6%97%B6%E9%97%B4
    print '=> the new access_token is : %s' % access_token 
    print 'access_token expires_in: ', expires_in
    #dump_tokens(access_token) 
    client.set_access_token(access_token, expires_in)
    data = client.users.show.get(uid=r.get('uid', None))
    nickname = data.screen_name
    id_pic =  data.profile_image_url
    client.access_token = access_token
    client.nickname = nickname
    access.insert({"nickname":nickname,"id_pic":id_pic,"access_token":access_token})
    conn.close()
    return HttpResponseRedirect("/access_login/?access_token="+access_token+"&nickname="+nickname)