Powncer!
Powncer is a Ruby library/wrapper to the Pownce REST API
Get It
Getting Started
irb(main):001:0> require 'powncer'
=> true
irb(main):002:0> include Powncer
=> Object
Powncer provides many objects for the Pownce API, with the two main objects being User and Note. While some actions require authentication to perform, some can produce both public (non-authenticated) and private (authenticated) results.
User
Profile
You can access a users public profile:
user.profile
- or -
You can access properties of a users profile:
=> "Jae H."
user.gender
=> "Bloke"
user.is_pro?
=> false
Friends, Fans, Fan of
You can access a users relationship data:
=> [#<Powncer::User:0x148e670 @attributes={....]
user.fans
=> []
user.fan_of.length
=> 2
=> "Andrew S."
Note
Find
Return properties on a specific note.
=> #<Powncer::Note:0x14a06b8>
note.body
=> "Powncer Ruby Gem released soon ..."
note.permalink
=> "http://pownce.com/jaehess/notes/1437687/"
You also have access to the sender object / recipient list:
=> #<Powncer::User:0x148e670>
note.sender.first_name
=> "Jae"
note.recipients
=> [#<Powncer::User:0x148e670 @attributes={....]
note.recipients.length
=> "7"
note.recipients.first.gender
=> "Bloke"
Note Lists
Returns a list of notes for the user (users public notes by default). If authenticated, will return the users typical Pownce stream. When accessing through a friend, you will see notes friend sent to you.
Public Note List
Returns an array of note objects from the Pownce public timeline.
=> [#<Powncer::Note:0x14a06b8>....]
notes.length
=> 20 # Default
lots_of_notes = Note.find(:public, {:limit => 100})
lots_of_notes.length
=> 100 # Max you can get in a single request lots_of_notes.first.body
=> "It takes a very long time...."
User Note Lists
Same results as the Public Note List, scoped to a user. You can also filter by types.
=> #<Powncer::User:0x148e670>
user.notes # all messages, events, and links
=> [#<Powncer::Note:0x14a06b8>....]
user.messages.length
=> 1
user.links.length
=> 1
user.events.length
=> 1
Authenticating
Before you can access any of the authenticated portions of the Pownce API, you must establish an authenticated connection.
Creating Basic Auth Connection
:secret_key=>"api_secret_key",
:username=>"username",
:application_key=>"api_application_key",
:password=>"password"
})
Environment Variables
You may specify the credentials with the following environment variables
ENV["POWNCER_SECRET_KEY"] = "api_secret_key"
ENV["POWNCER_USERNAME"] = "username"
ENV["POWNCER_PASSWORD"] = "password"
Example
=> #<Powncer::User:0x148e670>
user.notes.length
=> 3 # public notes length
Authentication::Basic.connect!
user.notes.length
=> 20 # all notes length
Posting
Post Message
Parameters are:
- :to
- options are: :all, :public or username
- :body
- text of the message
note.save
- or -
Post Link
Parameters are:
- :to
- options are: :all, :public or username
- :url
- full url of the link, including http://
- :body [optional]
- text of the message
link.save
- or -
Post Event
Parameters are:
- :to
- options are: :all, :public or username
- :name
- name of event
- :location
- location of the event
- :date
- date of the event in the format YYYY-MM-DD hh:mm
- :body [optional]
- text of the message
event.save
- or -
Posting Errors
The following errors are specific to creating / saving new notes
- InvalidFriend
- raised when target recipient is not in senders send to list
- RequirementMissing
- raised when a required attribute has not been specified
- InvalidFormat
- raised when either date/url formatting on Event/Link object is incorrect, respectively
Contribute
How to submit patches
Read the 8 steps for fixing other peoples code and for section 8c. Submit patch to RubyForge Tracker, use the Powncer Tracker.
Miscellaneous
To Do
- Implement send to Sets
- all filters on note lists
- Replying
- OAuth Connection Support
- File Upload
- Post Throttling
- since_id on Public Timeline
- implement XML as alternative to JSON, if JSON gem is not available
- Hash on association calls.
Ex, User.find('jaehess').friends({:limit => 100, :page => 2}) - RDoc