Esempio n. 1
0
def cc_indiegogo_signup(request):
    if request.method == "POST":
        constantcontact = ConstantContact(settings.CONSTANT_CONTACT_API_KEY, settings.CONSTANT_CONTACT_ACCESS_TOKEN, settings.CONSTANT_CONTACT_API_URL)
        contact = Contact()
        contact.add_list_id(settings.CONSTANT_CONTACT_LIST_ID)
        contact.set_email_address(request.POST['email'])
        response = constantcontact.post_contacts(contact)

        if response.has_key('error_key'):
            return HttpResponse(response['error_key'])
        else:
            return HttpResponse('201')
Esempio n. 2
0
def cc_indiegogo_signup(request):
    if request.method == "POST":
        constantcontact = ConstantContact(
            settings.CONSTANT_CONTACT_API_KEY,
            settings.CONSTANT_CONTACT_ACCESS_TOKEN,
            settings.CONSTANT_CONTACT_API_URL)
        contact = Contact()
        contact.add_list_id(settings.CONSTANT_CONTACT_LIST_ID)
        contact.set_email_address(request.POST['email'])
        response = constantcontact.post_contacts(contact)

        if response.has_key('error_key'):
            return HttpResponse(response['error_key'])
        else:
            return HttpResponse('201')
Esempio n. 3
0
from constantcontact import ConstantContact, Contact
from random import randint

import json
    
printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

test_email = 'test'+str(randint(1000000, 9999999))+'@example.com'

print '[test] get_contacts'
response = constantcontact.get_contacts(limit = 5)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

next_page = response.get_next_page()

print '[test] get_next_page'
response = constantcontact.next_page(next_page)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

contact_lists = constantcontact.get_lists()
from constantcontact import ConstantContact, Account_Info

import json
    
printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

print '[test] get_account_info'
response = constantcontact.get_account_info()
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

print '[test] put_account_info'
account_info = Account_Info()
account_info.set_phone('1234567890')
account_info.set_state_code('MA')

response = constantcontact.update_account_info(account_info)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

print '[test] get_verified_email_addresses'
response = constantcontact.get_verified_email_addresses()
from constantcontact import ConstantContact, Billing_Plan, Partner_Account, Result_Set
from random import randint

import json
    
printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

number = randint(0, 10000000)
phone = str(randint(100, 999))+'-'+str(randint(100, 999))+'-'+str(randint(1000, 9999))

account = Partner_Account()
account.set_username('testpartner'+str(number))
account.set_organization_name('Illuminati')
account.set_first_name('Please Help')
account.set_last_name('I\'m trapped in a software factory')
account.set_email('test'+str(number)+'@example.com')
account.set_phone(phone)
account.set_state_code('MA')
account.set_password(str(number))
account.set_country_code('US')
# TODO: Test with a real partner API key

print '[test] post_partner_accounts'
response = constantcontact.post_partner_accounts(account)
Esempio n. 6
0
from constantcontact import ConstantContact, Attribute, Contact, Event, Fee, Item, Promocode

from datetime import datetime, timedelta
from random import randint

import json
    
printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

print '[test] get_events'
response = constantcontact.get_events(limit = 3)
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

start_date = (datetime.now() + timedelta(hours=6)).replace(minute=0)
end_date = (datetime.now() + timedelta(days=5)).replace(minute=0)

verified_email_address = constantcontact.get_verified_email_addresses('CONFIRMED')[0]['email_address']

contact = Contact()
contact.set_email_address(verified_email_address)
contact.set_first_name('Bob')
contact.set_company_name('Justice League')
from constantcontact import Mylibrary_File, Mylibrary_Folder, Multipart_File

import json

from random import randint
import codecs

printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

multipart = Multipart_File()

multipart.set_data(open('constant_contact_logo.png', 'rb'))
multipart.set_description('The Constant Contact logo')
multipart.set_file_name('Constant Contact logo' +
                        str(randint(1000000, 9999999)))
multipart.set_file_type('PNG')
multipart.set_folder_id(0)
multipart.set_source('MyComputer')

print '[test] add_files'
response = constantcontact.post_files(multipart)
if printout and response:
    print response
from constantcontact import ConstantContact, Account_Info

import json

printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

print '[test] get_account_info'
response = constantcontact.get_account_info()
if printout and response:
    print json.dumps(response, indent=4, sort_keys=True)
    raw_input('press enter for next test')

print '[test] put_account_info'
account_info = Account_Info()
account_info.set_phone('1234567890')
account_info.set_state_code('MA')

response = constantcontact.update_account_info(account_info)
if printout and response:
    print json.dumps(response, indent=4, sort_keys=True)
    raw_input('press enter for next test')

print '[test] get_verified_email_addresses'
response = constantcontact.get_verified_email_addresses()
from constantcontact import ConstantContact, Campaign, Schedule
from random import randint

from datetime import datetime, timedelta

import json
    
printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

print '[test] get_campaigns'
response = constantcontact.get_campaigns()
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

campaign = response.get_item(0).get_id()

for c in response.get_set():
    if c.get_status() == 'SENT':
        sent_campaign = c
        break

print '[test] get_campaign'
response = constantcontact.get_campaign(campaign)
from constantcontact import ConstantContact

import json
    
printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

print '[test] post_lists'
response = constantcontact.post_lists('Test List 213')
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

print '[test] get_lists'
response = constantcontact.get_lists()
if printout and response:
    print json.dumps(response, indent = 4, sort_keys = True)
    raw_input('press enter for next test')

for l in response:
    if l.get_name().lower() == 'test list 1':
        target_list = l
        break

print '[test] get_list'
from constantcontact import Mylibrary_File, Mylibrary_Folder, Multipart_File

import json

from random import randint
import codecs
    
printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

multipart = Multipart_File()

multipart.set_data(open('constant_contact_logo.png', 'rb'))
multipart.set_description('The Constant Contact logo')
multipart.set_file_name('Constant Contact logo'+str(randint(1000000, 9999999)))
multipart.set_file_type('PNG')
multipart.set_folder_id(0)
multipart.set_source('MyComputer')

print '[test] add_files'
response = constantcontact.post_files(multipart)
if printout and response:
    print response
    raw_input('press enter for next test')
Esempio n. 12
0
from constantcontact import ConstantContact, Billing_Plan, Partner_Account, Result_Set
from random import randint

import json

printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

number = randint(0, 10000000)
phone = str(randint(100, 999)) + '-' + str(randint(100, 999)) + '-' + str(
    randint(1000, 9999))

account = Partner_Account()
account.set_username('testpartner' + str(number))
account.set_organization_name('Illuminati')
account.set_first_name('Please Help')
account.set_last_name('I\'m trapped in a software factory')
account.set_email('test' + str(number) + '@example.com')
account.set_phone(phone)
account.set_state_code('MA')
account.set_password(str(number))
account.set_country_code('US')
# TODO: Test with a real partner API key

print '[test] post_partner_accounts'
Esempio n. 13
0
from constantcontact import ConstantContact, Campaign, Schedule
from random import randint

from datetime import datetime, timedelta

import json

printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

print '[test] get_campaigns'
response = constantcontact.get_campaigns()
if printout and response:
    print json.dumps(response, indent=4, sort_keys=True)
    raw_input('press enter for next test')

campaign = response.get_item(0).get_id()

for c in response.get_set():
    if c.get_status() == 'SENT':
        sent_campaign = c
        break

print '[test] get_campaign'
response = constantcontact.get_campaign(campaign)
Esempio n. 14
0
from constantcontact import ConstantContact, Contact, Multipart_Activity

import json
    
from random import randint

printout = True

creds_file = open('creds.txt', 'r')
access_token = creds_file.readline().replace('\n', '')
api_key = creds_file.readline().replace('\n', '')
api_url = creds_file.readline().replace('\n', '')

constantcontact = ConstantContact(api_key, access_token, api_url)

contact1 = Contact()
contact1.set_email_address('*****@*****.**')
contact1.set_first_name('Albus')

contact2 = Contact()
contact2.set_email_address('*****@*****.**')
contact2.set_first_name('Severus')

import_data = []
import_data.append(contact1)
import_data.append(contact2)

contact_lists = constantcontact.get_lists()

for l in contact_lists:
    if l.get_name().lower() == 'general interest':