Exemplo n.º 1
0
def displayStats(request, data_id):
    try:
        data = fbDataRequest.objects.get(pk=data_id)
    except Exception as e:
        print e
    facebook = fbDataRequest()
    form = dataForm(instance=facebook)
    return render_to_response(
        "fbsharing/url_form.html", {"form": form, "data": data}, context_instance=RequestContext(request)
    )
Exemplo n.º 2
0
def getFacebookStats(request):
    facebook = fbDataRequest()
    if request.method == "POST":
        if linkValid(request.POST["url"]):
            form = dataForm(request.POST, instance=facebook)
            if form.is_valid():
                try:
                    facebook = form.save()
                    # return redirect('fbsharing.views.getRecentTweets', facebook.id)
                    callback_url = "http://" + request.META["HTTP_HOST"] + "/fb/betterStats/" + str(facebook.id)
                    return HttpResponseRedirect(
                        REQUEST_TOKEN_URL
                        + "?client_id=%s&client_secret=%s&grant_type=client_credentials&redirect_uri=%s"
                        % (APP_ID, APP_SECRET, callback_url)
                    )
                except Exception as e:
                    print "Data Request object failed to save"
    form = dataForm(instance=facebook)
    return render_to_response("fbsharing/fb_url_form.html", {"form": form}, context_instance=RequestContext(request))
Exemplo n.º 3
0
def getFacebookStats(request):
    facebook = fbDataRequest()
    if request.method == 'POST':
        if linkValid(request.POST['url']):
            form = dataForm(request.POST, instance=facebook)
            if form.is_valid():
                try:
                    facebook = form.save()
                    # return redirect('fbsharing.views.getRecentTweets', facebook.id)
                    callback_url = 'http://' + request.META[
                        'HTTP_HOST'] + '/fb/betterStats/' + str(facebook.id)
                    return HttpResponseRedirect(
                        REQUEST_TOKEN_URL +
                        '?client_id=%s&client_secret=%s&grant_type=client_credentials&redirect_uri=%s'
                        % (APP_ID, APP_SECRET, callback_url))
                except Exception as e:
                    print "Data Request object failed to save"
    form = dataForm(instance=facebook)
    return render_to_response('fbsharing/fb_url_form.html', {'form': form},
                              context_instance=RequestContext(request))
Exemplo n.º 4
0
def displayStats(request, data_id):
    try:
        data = fbDataRequest.objects.get(pk=data_id)
    except Exception as e:
        print e
    facebook = fbDataRequest()
    form = dataForm(instance=facebook)
    return render_to_response('fbsharing/url_form.html', {
        'form': form,
        'data': data
    },
                              context_instance=RequestContext(request))
Exemplo n.º 5
0
def getFacebookStats(request):
    facebook = fbDataRequest()
    if request.method == "POST":
        if linkValid(request.POST["url"]):
            form = dataForm(request.POST, instance=facebook)
            if form.is_valid():
                try:
                    facebook = form.save()
                    return redirect("fbsharing.views.getBetterFacebookStats", facebook.id)
                    # This callback URL allows facebook to redirect back to our server once OAuth login has been completed
                    # The callback url for the Access Token request must be identical to the one being used here (to request a code to exchange for an access token)
                    callback_url = "http://" + request.META["HTTP_HOST"] + "/fb/betterStats/" + str(facebook.id)
                    return HttpResponseRedirect(
                        REQUEST_TOKEN_URL
                        + "?client_id=%s&client_secret=%s&grant_type=client_credentials&redirect_uri=%s"
                        % (APP_ID, APP_SECRET, callback_url)
                    )
                except Exception as e:
                    print "Data Request object failed to save"
    form = dataForm(instance=facebook)
    return render_to_response("fbsharing/fb_url_form.html", {"form": form}, context_instance=RequestContext(request))
Exemplo n.º 6
0
def getFacebookStats(request):
    facebook = fbDataRequest()
    if request.method == 'POST':
        if linkValid(request.POST['url']):
            form = dataForm(request.POST, instance=facebook)
            if form.is_valid():
                try:
                    facebook = form.save()
                    return redirect('fbsharing.views.getBetterFacebookStats',
                                    facebook.id)
                    # This callback URL allows facebook to redirect back to our server once OAuth login has been completed
                    # The callback url for the Access Token request must be identical to the one being used here (to request a code to exchange for an access token)
                    callback_url = 'http://' + request.META[
                        'HTTP_HOST'] + '/fb/betterStats/' + str(facebook.id)
                    return HttpResponseRedirect(
                        REQUEST_TOKEN_URL +
                        '?client_id=%s&client_secret=%s&grant_type=client_credentials&redirect_uri=%s'
                        % (APP_ID, APP_SECRET, callback_url))
                except Exception as e:
                    print "Data Request object failed to save"
    form = dataForm(instance=facebook)
    return render_to_response('fbsharing/fb_url_form.html', {'form': form},
                              context_instance=RequestContext(request))