parcelforce.txt
To track a Parcelforce consignment programatically:
https://app.parcelforce.com/api/GetTrackData/UG111111111/0?callback=no
Replace UG11111.. with your consignment number.
Code to then look at the data:
require 'http'
require 'json'
require 'awesome_print'
consignment = ARGV.first
stop_position = 0
loop do
res = HTTP.get("https://app.parcelforce.com/api/GetTrackData/#{consignment}/0?callback=no")
raise "Failure #{res.code}" unless res.code == 200
data = res.body.to_s
data.sub!(/\)\;/, '')
data.sub!("/**/ typeof no === 'function' && no(", "")
data = JSON.parse(res)["Routes"].first
my_stop = data["CustomerStopNumber"].to_i
last_stop = data["LastStopNumber"].to_i
if last_stop > stop_position
stop_position = last_stop
puts "Last stop: #{last_stop} My stop: #{my_stop}"
puts "#{my_stop - last_stop} stops to go"
puts "#{last_stop},#{data["LastStopLocation"]["Latitude"]},#{data["LastStopLocation"]["Longitude"]}"
end
puts "Sleeping"
sleep 90
end
tcp.rip