Giter VIP home page Giter VIP logo

topsy's Introduction

Topsy

Simple Ruby wrapper for the Topsy.com Otter API. Topsy is a search engine powered by tweets.

Installation

Topsy is hosted on Gemcutter, so:

sudo gem install topsy

Usage

# grab your API key from http://manage.topsy.com/app/
Topsy.configure do |config|
  config.api_key = "ENTER-YOUR-KEY"
end

>> Topsy.rate_limit
=> <#Topsy::RateLimitInfo limit=10000 remaining=10000 reset=1262804400>

>> Topsy.author_info('http://twitter.com/barackobama')
=> <#Topsy::Author description="44th President of the United States" influence_level=10 name="Barack Obama" nick="barackobama" topsy_author_url="http://topsy.com/twitter/barackobama" type="twitter" url="http://twitter.com/barackobama">

>> Topsy.experts('programming')
=> <#Topsy::Page list=[<#Topsy::Author descript ... ] page=1 perpage=15 topsy_trackback_url=nil total=97229 window=nil>

>> Topsy.experts('programming', :perpage => 2, :page => 1)
=> <#Topsy::Page list=[<#Topsy::Author description="Most ... ] page=1 perpage=2 topsy_trackback_url=nil total=100685 window=nil>

>> Topsy.link_posts('http://twitter.com/barackobama', :perpage => 2, :page => 2)
=> <#Topsy::Page list=[<#Topsy::Linkpost content="An important reminder ... ] page=2 perpage=2 topsy_trackback_url=nil total=402 window=nil>

>> Topsy.link_posts('http://twitter.com/barackobama')
=> <#Topsy::Page list=[<#Topsy::Linkpost content="An important reminder about health reform on the @Whit... ] page=1 perpage=10 topsy_trackback_url=nil total=402 window=nil>

>> Topsy.link_post_count('http://twitter.com/barackobama')
=> <#Topsy::LinkpostCount all=402 contains=0>

>> Topsy.url_info('http://etagwerker.com')
=> <#Topsy::UrlInfo description="" description_attribution="" oneforty="just finished installing wordpress in a linux .." url="http://etagwerker.com/">

>> Topsy.stats('http://www.google.com')
=> <#Topsy::Stats all=29869 contains=0 influential=2023 topsy_trackback_url="http://topsy.com/tb/www.google.com/">

>> Topsy.search('rock')
=> <#Topsy::Page list=[<#Topsy::LinkSearchResult content="Why 30 Rock is a Rip-Off of The Muppet Show - http://is.gd/15KJZ" .. ]  page=1 perpage=10 topsy_trackback_url=nil total=714429 window="a">

>> Topsy.search('rock', :perpage => 2, :page => 3)
=> <#Topsy::Page list=[<#Topsy::LinkSearchResult content="Just released! Beatles Rock Band opening cinematic. Amaz ..." ] page=3 perpage=2 topsy_trackback_url=nil total=714429 window="a">

>> Topsy.search('rock', :perpage => 2, :page => 3, :window => 'd')
=> <#Topsy::Page list=[<#Topsy::LinkSearchResult content="Be a Google Wave Rock Star http://ff.im/-dPdGL" highlight="Be a .. "] page=3 perpage=2 topsy_trackback_url=nil total=6064 window="d">

>> Topsy.search_count('rock')
=> <#Topsy::SearchCounts a=5191790 d=7601 h=206 m=216179 w=45462>

>> Topsy.related('http://www.twitter.com')
=> <#Topsy::Page list=[<#Topsy::LinkSearchResult title="New Twitter Feature: Body Counts | Danger Room ... ">] page=1 perpage=10 topsy_trackback_url=nil total=4458 window=nil>

>> Topsy.tags('http://twitter.com')
=> <#Topsy::Page list=[<#Topsy::Tag name="current" url="http://topsy.com/s?q=current">, <#Topsy::Tag name="twe ... ">] page=1 perpage=10 topsy_trackback_url=nil total=1885 window=nil>

>> Topsy.trending
=> <#Topsy::Page list=[<#Topsy::Trend term="u s reopens embassy in yemen" url="http://topsy.com/s?q=u+s%20r ... ">] page=1 perpage=10 topsy_trackback_url=nil total=1434 window=nil>

>> Topsy.trending(:page => 3, :perpage => 2)
=> <#Topsy::Page list=[<#Topsy::Trend term="droid vs iphone" url="http://topsy.com/s?q=droid+vs%20iphone" ... ">] page=3 perpage=2 topsy_trackback_url=nil total=1434 window=nil>

>> Topsy.trackbacks('http://twitter.com', :perpage => 2, :page => 2)
=> <#Topsy::Page list=[<#Topsy::Tweet author=<#Topsy::Author influence_level=8 name="tama" photo_url="http://a3.twimg .. ">] page=2 perpage=2 topsy_trackback_url="http://topsy.com/tb/twitter.com/" total=39705 window=nil>

>> Topsy.trackbacks('http://twitter.com', :perpage => 2, :page => 2, :contains => 'mashable')
=> <#Topsy::Page list=[<#Topsy::Tweet author=<#Topsy::Author name="Hannah Grosvenor" photo_url="http://a1.t. ... >] page=2 perpage=2 topsy_trackback_url="http://topsy.com/tb/twitter.com/" total=41 window=nil>

# Fetch search results for the query "gemcutter"
>> results = Topsy.search("gemcutter")
=> <#Topsy::Page list=[<#Topsy::LinkSearchResult content="New design ... ]>

# Fetch search counts for the query "gemcutter"
>> counts = Topsy.search_count("gemcutter")
=> <#Topsy::SearchCounts a=773 d=6 h=0 m=103 w=24>
>> counts.this_week
=> 24

Check the full gem documentation and API docs for more info.

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2010 Wynn Netherland. See LICENSE for details.

topsy's People

Contributors

benbjohnson avatar biznickman avatar eichert12 avatar mhfs avatar orangewolf avatar pengwynn avatar scottwater avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

topsy's Issues

undefined method 'permalink=' error

When i use this gem in my irb, an error occurred. dump is below:

Topsy.trackbacks('http://bit.ly/bXlhni', :perpage => 50)
NoMethodError: undefined method permalink=' for <#Topsy::Tweet>:Topsy::Tweet from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:81:insend'
from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:81:in initialize' from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:80:ineach_pair'
from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:80:in initialize' from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy/page.rb:39:innew'
from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy/page.rb:39:in list=' from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy/page.rb:39:ineach'
from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy/page.rb:39:in list=' from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:81:insend'
from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:81:in initialize' from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:80:ineach_pair'
from /Library/Ruby/Gems/1.8/gems/hashie-0.4.0/lib/hashie/dash.rb:80:in initialize' from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy/page.rb:33:ininitialize'
from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy/client.rb:156:in new' from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy/client.rb:156:intrackbacks'
from /Library/Ruby/Gems/1.8/gems/topsy-0.3.1/lib/topsy.rb:148:in `trackbacks'
from (irb):2>> exit

:window options appears to have no effect

Both of these queries return the same result:

@news  = Topsy.search("topsy", :perpage => 3, :page => 1, :window => 'd3')

@news  = Topsy.search("topsy", :perpage => 3, :page => 1, :window => 'a')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.