def fbapp_home(request): #print request.GET["check"] #print request.POST #print request.GET facebook = Facebook() if request.POST.has_key('signed_request'): facebook.load_signed_request(request.POST['signed_request']) #if not facebook.user_id: # print "not signed in or no access" #print request.POST #if request.GET.has_key('code'): # return HttpResponseRedirect(settings.FBAPP_URL) print "access====================="+str(facebook.access_token) #print "user======================="+str(facebook.user_id) if facebook.access_token: #print facebook.user_info(param = 'friends') request.session['access_token'] = facebook.access_token return render_to_response("fbapp/dashboard.html", context_instance = RequestContext(request)) else: return render_to_response("fbapp/index.html", context_instance = RequestContext(request, {"fbapp_canvas" : settings.FBAPP_URL, "fbapp_id" : settings.FBAPP_ID}))
def friends_list(request): response = reply_object() if request.session.has_key('access_token'): facebook = Facebook() facebook.access_token = request.session['access_token'] friends_data = facebook.user_info(param = 'friends') print friends_data["data"] response["page"] = render_to_string("fbapp/friends_list.html", {"friends":friends_data["data"][:10]}) response["code"] = settings.APP_CODE["PAGE LOADED"] return HttpResponse(simplejson.dumps(response))