This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# This script performs an OAuth authorized POST with multipart encoding to | |
# http://twitter.com/account/update_profile_image.json | |
# | |
# This code is primarily taken from my Grackle library's implementation at | |
# http://github.com/hayesdavis/grackle | |
# | |
# RUNNING THIS WILL CHANGE AN ACCOUNT'S PROFILE IMAGE. BE CAREFUL. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#These instructions are for <= 0.1.3. Newer versions of Grackle will have a more | |
#fully-baked way of handling the Twitter API versions. | |
require 'grackle' | |
#Option 1: Just setup the hosts on your Grackle instance | |
#This will only change the hosts for this instance | |
client = Grackle::Client.new | |
client.api_hosts[:v1] = 'api.twitter.com/1' | |
client.api = :v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'grackle' | |
require 'redis' | |
# Shows the list of mutual followers between two Twitter users using Redis | |
# sets and set intersections. | |
# | |
# Usage: | |
# ruby mutual_followers screen_name1 screen_name2 [reset] | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = Grackle::Client.new(:api=>:v1) | |
term = 'foo' | |
page = with_retry{client.search?(:q=>term,:rpp=>100)} | |
has_results = !page.results.empty? | |
while(has_results) | |
# page.results has tweets in it | |
unless page.next_page.nil? | |
page = with_retry{client.search?(:q=>term, :rpp=>100, :page=>page.page+1, :max_id=>page.max_id)} | |
has_results = !page.results.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Operation failed with the following exception: Connection reset by peer - send(2) | |
/usr/lib/ruby/gems/1.8/gems/mongo-0.18/lib/../lib/mongo/connection.rb:503:in `send_message_on_socket' | |
/usr/lib/ruby/gems/1.8/gems/mongo-0.18/lib/../lib/mongo/connection.rb:209:in `send_message' | |
/usr/lib/ruby/gems/1.8/gems/mongo-0.18/lib/../lib/mongo/collection.rb:257:in `update' | |
/usr/lib/ruby/gems/1.8/gems/mongo-0.18/lib/../lib/mongo/collection.rb:179:in `save' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = Grackle::Client.new(:auth=>{:type=>:basic,:username=>SOME_USER,:password=>SOME_PASS},:ssl=>true) | |
# The ! means POST | |
client.direct_messages.new! :screen_name=>'hayesdavis', :text=>'testing' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup grackle to talk to flamingo | |
client = Grackle::Client.new | |
client.api_hosts[:flamingo] = "http://localhost:4711" | |
client.api = :flamingo | |
# Commence talking | |
# See what's being filtered | |
client.streams.filter? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client = Grackle::Client.new(:auth=>{ | |
:type=>:oauth, | |
:consumer_key=>'SOMECONSUMERKEYFROMTWITTER', # Ids your app. "Consumer Key" on Twitter app page | |
:consumer_secret=>'SOMECONSUMERTOKENFROMTWITTER', # Your app's secret. "Consumer Secret" on Twitter app page | |
:token=>'ACCESSTOKENACQUIREDONUSERSBEHALF', # Ids a user. Most docs call this "access token". | |
:token_secret=>'SUPERSECRETACCESSTOKENSECRET' # Secret for a user. Often called "access token secret". | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Below is a template for implementing the "OAuth Dance" with Twitter using the Ruby OAuth gem in a Rails app. | |
# Ruby OAuth gem is required by grackle and is found here: http://github.com/oauth/oauth-ruby | |
## | |
# Step 1: User clicks "Sign in with Twitter" button | |
# Step 2: User is routed to your controller action that looks like the method below | |
def start_oauth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'grafl' | |
# Get the root node (assumes you have an access token) | |
root = Grafl.root(:access_token=>'foo') | |
# Get the current user | |
user = root/:me | |
puts user.name | |
# Get the user's news feed |
OlderNewer