Aweber Integration

This guide assumes you have nothing previously setup to work with the AWeber API. It will walk through registering an account, creating an app and everything up to the point where you’ll actually start working with data.

If you don’t want to bother with all the account setup stuff, you can look in the examples directory for just example code.

1. Register an AWeber Labs Account

Head to http://labs.aweber.com and sign up for a free AWeber Labs account. This is how you register apps and get OAuth keys.

2. Create an App

Once logged in, Create a New App. Once created, it will show you the Consumer Key and Secret for that app.

3. Write Some Code

The OAuth Handler

oauth = AWeber::OAuth.new('consumer_key', 'consumer_secret')

Authorize an Account

Open, what the following outputs, in a browser and use your AWeber account credentials. This will give your app permission to work with your account’s data:

oauth.request_token.authorize_url

If you go to that URL you will see
aweber_1

This form will only authenticate your app to access the lists and count of subscribers but not subscriber details. You cannot access names, email, etc of subscribers

 

 

 

aweber_3

This form shows that the app is willing to access some more details of the subscribers too. With this type of access form; your app can access the subscriber details too and you can search any customer details using API


AWEBER_2

A callback url may also be passed by setting the :oauth_callback parameter:

oauth.request_token(:oauth_callback => 'http://www.example.com').authorize_url


For more details about Authorization, see https://cbabhusal.wordpress.com/2015/12/13/aweberforbiddenrequesterror-method-requires-extended-permissions/

Verification Code

After you do the above step, it will output a “Verification Code”. Copy this and verify your oauth object:

oauth.authorize_with_verifier('verification_code')

Grab an AWeber::Base

aweber = AWeber::Base.new(oauth)

This object is how you access data from your account. aweber.account is your account object which is the stem for all other resources.

What if I don’t want to verify every time?

After verifying once, the oauth object contains an oauth.access_token.token and and oauth.access_token.secretwhich may be used to authorize your application without having to verify via url:

...
oauth.authorize_with_verifier('verification_code')
puts 'Access token: ' + oauth.access_token.token
puts 'Access token secret: ' + oauth.access_token.secret

The token and secret can then be saved, and authorization can be performed as follows:

require 'aweber'
oauth = AWeber::OAuth.new('consumer_key', 'consumer_secret')
#Rather than authorizing with the verification code, we use the token and secret
oauth.authorize_with_access(YOUR_ACCESS_TOKEN, YOUR_ACCESS_TOKEN_SECRET)
aweber = AWeber::Base.new(oauth)

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s