Permalink
Browse files

WIP

  • Loading branch information...
1 parent 64686cb commit d0c93423f665680afa3539ba83c4d3300bd75eb7 @mattyoho mattyoho committed Feb 28, 2012
Showing with 11 additions and 15 deletions.
  1. +11 −15 source/projects/jstwitter.markdown
@@ -53,7 +53,7 @@ class JSTwitter
end
```
-Then, with an IRB session that was started in your project's working directory, do the following:
+Then, start an IRB session for your project's working directory with `irb -I./`, and do the following:
```ruby
require 'jstwitter'
@@ -71,7 +71,7 @@ Initializing
### Dealing with OAuth
-Recently Twitter disabled the "basic" authentication. It was much easier than the OAuth system they use now, but they're forcing us to update. The OAuth authentication system is a more complex private/public key exchange and will require a few extra steps. I wrapped up all the complexity into the `jumpstart_auth` gem so it'll look easy to you! You just need to use my library inside your initialize method...
+When connecting to a third-party service, from the developer's perspective, possibly the simplest form of authentication is simply passing the user's username and password. Unfortunately, this puts more work on the user and is less secure than more robust schemes such as OAuth. The OAuth authentication system is a more complex private/public key exchange that requires several steps and a difficult-to-follow workflow that requires a handshake with the remote service. So that we can focus on the important parts of this exercise, all this complexity has been pushed into the `jumpstart_auth` gem. You just need to use this library inside your initialize method...
```ruby
def initialize
@@ -98,7 +98,7 @@ The result is that we have a `@client` variable which is our connection to Twitt
## Iteration 1: Posting Tweets
-Posting tweets is easy now that we have the `@client` object, but we need to know what methods are available from the library. This library is not very well documented. The best information is available on the GitHub project readme file here: "https://github.com/jnunemaker/twitter":https://github.com/jnunemaker/twitter
+Posting tweets is easy now that we have the `@client` object, but we need to know what methods are available from the library. This library is not very well documented. The best information is available on the [project readme file here](http://rdoc.info/gems/twitter/file/README.md).
In the readme you'll find a section "Usage Examples" which clues you into some of the functions exposed by the library.
@@ -125,7 +125,7 @@ Then run your code by going to your terminal/command-prompt an entering:
ruby jstwitter.rb
```
-You should see the output say `Initializing`. Now go to "http://twitter.com/your_testing_account_username":http://twitter.com/your_testing_account_username and look for your
+You should see the output say `Initializing`. Now go to [your test account's Twitter page](http://twitter.com/your_testing_account_username) and look for your
results!
#### Step 2 - Length Restrictions
@@ -261,7 +261,7 @@ But those `parts[1..-1]` are individual word strings, I need to join them into a
command = parts[0]
case command
when 'q' then puts "Goodbye!"
- when 't' then tweet #tweet(parts[1..-1].join(" "))
+ when 't' then tweet(parts[1..-1].join(" "))
else
puts "Sorry, I don't know how to (#{command})"
end
@@ -310,16 +310,12 @@ Let's add a way to verify that the target is following you before sending the me
* If the target is in this list, send the DM
* Otherwise, print an error message
-We can call `@client.followers.users` which gives us back a list of all our followers but includes lots of information we don't need right now like their follower count, web address, last tweet. All we want is to find their `screen_name`. When you call @client.followers.users` you get an array where each element in the array is a hash. Each hash is for one user and has several keys:
-
-```ruby
-["profile_background_tile", "name", "profile_sidebar_fill_color", "profile_sidebar_border_color", "created_at", "profile_image_url", "location", "profile_link_color", "url", "favourites_count", "utc_offset", "id", "profile_text_color", "followers_count", "protected", "notifications", "description", "verified", "profile_background_color", "time_zone", "profile_background_image_url", "friends_count", "status", "statuses_count", "following", "screen_name"]
-```
+We can call `@client.followers` which gives us back a list of all our followers but includes lots of information we don't need right now like their follower count, web address, last tweet. All we want is to find their `screen_name`.
What we need to do is pull out just the `screen_name`. We create an array of the followers' screen names with this line of code:
```ruby
-screen_names = @client.followers.users.collect{|follower| follower.screen_name}
+screen_names = @client.followers.collect{|follower| follower.screen_name}
```
To read this line out loud it would be like "Call the `followers` method of `@client`, then take that array and, for each element in the array, `collect` together the value of `screen_name`.
@@ -369,14 +365,14 @@ So now you can post tweets and DMs. There are hundreds of clients that can do t
Here it is in pseudocode:
* Find the list of people you follow
* For `each` member of the list...
-** Find their latest tweet
-** Print out their `screen_name` and latest tweet
+ - Find their latest tweet
+ - Print out their `screen_name` and latest tweet
Turn that into code like this...
```ruby
def everyones_last_tweet
- friends = @client.friends.users
+ friends = @client.friends
friends.each do |friend|
# find each friends last message
# print each friend's screen_name
@@ -505,4 +501,4 @@ You know that `parts[0]` is the command, `parts[1..-2]` are the message, and `pa
`tweet(parts[1..-2].join(" ") + " " + shorten(parts[-1]))`
-Get that working and you're done with the twitter client!
+Get that working and you're done with the twitter client!

0 comments on commit d0c9342

Please sign in to comment.