iPhone Backorder Status
Posted on July 18, 2008 at 09:08 AM
UPDATE (20080729): AT&T put a captcha on the order status page, so the script below no longer works. It was fun while it lasted.
Lots of people ordered iPhones at AT&T locations under the Direct Fulfillment method, and we are getting anxious. They are shipping out, but in more of a trickle than a flood. I found a forum of other people who are just as neurotic about it as I am, which makes me feel a little better. This time last week was the Day Of The iPhone Launch, and I was like a kid on Christmas morning. I could Not Sit Still.
So now we wait.
Someone on the forum whipped up a screen scraping script that would tell you how the orders for the store you placed your order is fairing. We brought his server down. He came up with another version of the page, which is here.
I also decided to whip up a quick and dirty ruby script that does the same thing. I called it att.rb on my compy.
UPDATE: fixed some formatting with the code vs blog markup and added the queue. UPDATE 2: redid code to be a little more ruby and a lot less perl. UPDATE 3: Added better reporting on cancel status.
#!/usr/local/bin/ruby
require 'rubygems'
require 'open-uri'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
ORDER_NUMBER_LOWER_LIMIT = 15183
ORDER_NUMBER_UPPER_LIMIT = 15270
ZIPCODE = 12345
queue = 0
class OrderStatus
attr_accessor :response
def initialize(response)
self.response = response
end
def nil?
err = self.response.scan("We're sorry, but the information you entered was not").to_s
err.empty? == true ? false : true
end
def canceled?
cancel = self.response.scan("Canceled")[0].to_s
cancel.empty? == true ? false : true
end
def name
name = self.response.scan(/Customer:\s*\w*/).to_s
name.gsub!(/Customer:\s*/, "")
end
def order
order = self.response.scan(/Order Number:\s*\w*/).to_s
order.gsub!(/Order Number:\s*/, "")
end
def date
date = self.response.scan(/Date Ordered:.*/).to_s
date.gsub!(/Date Ordered:\s*/, "")
date.gsub!(/\s/, "")
end
def ship_date
ship_date = self.response.scan(/\<td width="6%".*/)[5]
ship_date.remove_p_tag
end
def shipped
shipped = self.response.scan(/\<td width="5%".*/)[3].scan(/[01]/).to_s.to_i
end
def ship_info
ship_info = self.response.scan(/\<td width="6%".*/)[7]
ship_info.remove_p_tag
end
def display(q)
"#{name.slice(0..20).ljust(20)} | #{order} | #{date} | #{shipped} | #{q.rjust(2)} | #{ship_date} #{ship_info}"
end
end
class String
# add this to the String class to help clean up some cruft
def remove_p_tag
self.gsub!(/^.*\<p\>/, "")
self.gsub!(/\<\/p\>.*$/, "")
end
end
puts "Name | Order | Order Dt |Yn | Qu | Ship Info "
for order_number in ORDER_NUMBER_LOWER_LIMIT..ORDER_NUMBER_UPPER_LIMIT
@url = "https://www.wireless.att.com/order_status/order_status_results.jsp?fromwhere=order_status&vMethod=ordernum&vNumber=#{order_number}&ZipCode=#{ZIPCODE}&x=48&y=6"
# open-uri RDoc: http://stdlib.rubyonrails.org/libdoc/open-uri/rdoc/index.html
open( @url,
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "email@addr.com",
"Referer" => "https://www.wireless.att.com/order_status") { |f|
# Save the response body
stat = OrderStatus.new(f.read)
if stat.canceled?
puts "#{order_number} canceled"
elsif !stat.nil?
# calculate the queue
queue += 1 if stat.shipped == 0
display_queue = stat.shipped == 0 ? queue.to_s : ""
# display the info
puts stat.display(display_queue)
else
puts "#{order_number} not found"
end
}
end
It could be a lot prettier, but it works. It will also hopefully take some of the load off the webserver since you can just run this on your local mac. You've got ruby on it already, although it may not be in /usr/local/bin. If it doesn't run, you can take out that shebang line and just run the script like this:
ruby att.rb
There you have it. Good luck to all of us.
Comments
There are 13 comments on this post. Post yours →
I've written an order status checked with RSS support if people are interested in checking their status without ruby. You can find it here: http://nsb1.info/~bmichalski/iphone.php?zip=01040&po=9711
Change the zip and purchase order # appropriately.
hey how do i get the ruby script to run on my mac?
How to run:
You should be good to go.
Just to let you know it crashes with a canceled order.
PM at Diode on macrumors site for a example.
Strange. It was working for me, but I didn't display the cancel status. All better now.
doesn't tell me anything different than the info I can get from the email Apple sent me with tracking info.
Mark - it tells you how a range of orders is doing. If your order hasn't shipped yet you may be interested in seeing how many orders are ahead of you. You won't know what the phones are, but you will have an idea of whether there are 100 unfilled orders or 10.
how can i use this on windows?? im not great with computers so help is appreciated, thanks!!
anon - You can run ruby on windows, but I've never done it personally. There is even a windows user group called "Softies on Rails" of ruby on rails devs who use windows. Check out the 1-click installer: http://rubyinstaller.rubyforge.org/wiki/wiki.pl?RubyInstaller
Feel free to email me if you're still stuck. I have windows on a couple of my macs (work + home). Good luck.
Thanks for the great tool. I plopped it into a pico document and it just works. I'm confused to what the last field means. Some dates have an "F" and others have a "FDE51". Do they mean something different, ie. one means shipped and other means activated?
It appears AT&T has put an authentication wall up. The tool was running fine until I got errors in the middle of a scan. Now when you visit the iPhone page it requires you to type in characters embedded in an image.
RATS!!!
newton:desktop brad$ ruby att.rb att.rb:6: warning: already initialized constant VERIFY_PEER Name | Order | Order Dt |Yn | Qu | Ship Info
att.rb:52:in
shipped': private methodscan' called for nil:NilClass (NoMethodError) from att.rb:88 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:135:inopen_uri' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:519:inopen' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:30:inopen' from att.rb:78 from att.rb:74:ineach' from att.rb:74Brad - thanks for the kind words and the info.
Yes - AT&T put a captcha on the order status page. The screen scrapers are out of business. I'm surprised it took so long, really.
The different info in that last column is just junk. I wasn't too concerned with the exact contents of that data. My focus was less on giving the precise person-by-person info than the general status.
I captured the output and pretty much know that the store that I bought my iPhone is on about an 8-10 day turn around.
Date ordered and shipped are very close together for some users (same day or next day). It's safe to presume these are white 16GB iPhones.
Again, thanks for all the effort. It's been fun! Drop a post if you find a way around the captcha!
...Brad
Post a comment
Required fields in bold.