Exemplo n.º 1
0
def home(request):
    FacebookAdsApi.init(access_token=access_token,
                        app_id=app_id,
                        app_secret=app_secret)

    my_account = AdAccount('act_' + user_id)

    campaign = Campaign(parent_id=my_account.get_id_assured())

    context = {"id": campaign.get_id()}
    return render(request, 'fbapp/home.html', context)
Exemplo n.º 2
0
def create_campaign(request):
    FacebookAdsApi.init(access_token=access_token,
                        app_id=app_id,
                        app_secret=app_secret)

    my_account = AdAccount('act_' + user_id)

    campaign = Campaign(parent_id=my_account.get_id_assured())
    campaign[Campaign.Field.name] = "Campaign created by afnan -" + str(
        random.randint(1, 10))
    campaign[Campaign.Field.objective] = 'LINK_CLICKS'
    campaign[Campaign.Field.status] = 'ACTIVE'

    campaign.remote_create()

    result = {"id": campaign.get_id()}

    return redirect('view-campaign')