Official AWeber API gem.
gem install aweber
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.
Requires a normal AWeber account (not a 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.
Once logged in, Create a New App. Once created, it will show you the Consumer Key and Secret for that app.
oauth = AWeber::OAuth.new('consumer_key', 'consumer_secret')
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
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')
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. Take a look at the next section, “Usage”, to find out how to work with different resources.
Getting resource data is much like traversing associations in ActiveRecord. Everything starts with the account
object and goes from there:
aweber.account.lists #=> #<AWeber::Collection>
aweber.account.lists[123] #=> #<AWeber::Resource::List>
aweber.account.lists[123].name #=> "WhateverList"
aweber.account.lists
in the example above would be a Collection. Collections act like a normal Hash. Resources of a collection are accessed normally, using []
with the key being the ID of the resource.
Collections also support ActiveRecord style find_by_*
methods:
aweber.account.lists.find_by_name("testlist")
Resources are elements of a Collection. A single list resource would be retrieved with:
aweber.account.lists[1234]
Currently, subscribers are the only resource you can update via the API. Everything else is read only for the time being.
- name
- misc_notes
- status
- last_followup_message_number_sent
- custom_fields (Hash of key/value pairs)
- ad_tracking
new_list = aweber.account.lists[1234]
subscriber.list = new_list
subscriber = account.lists[654321].subscribers[123456]
subscriber.name = "New Name"
subscriber.save
- Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
- Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
- Fork the project
- Start a feature/bugfix branch
- Commit and push until you are happy with your contribution
- Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
- Please try not to mess with the Rakefile or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright © 2010-2011 AWeber Communications, Inc. See LICENSE for more detail.