You may have noticed that esnipe.com has started charging for their service. Fair enough. But I hate the thought of paying for something I can program myself. I think this is called righteous indignation, thus the birth of http://cniper.com
I am a graphics guy by day, and so knew that to create an auction sniping site would be a challenge. The toughest part would be extracting the data about the auction from ebay's pages. A little source code viewing quickly revealed ebays bidding system protocols. They are very simple.
To place a bid on ebay you need to send the obvious variables, like username, password, maximum bid, quantity and auction item number. But there is another variable called "key". It is sent as a hidden tag from the login screen after you have declared your maximum bid on actual item viewing page.
Here's the critical line from a recent auction:
<input type=hidden name=item value=1238546294><input type=hidden name=key value=$1$23187461$8pOqejD/opnGPcVLA5c11/><input type=hidden name=maxbid value=325.00>
Now I am sure some real code warrior could hack out a fail-safe regular expression to extract this hidden key in 12 seconds or less. But he wasn't here. I was. There had to be a better way.
Enter the php explode() function. With simple 4 lines of code I have the hidden keys being written to the database for cniper.com flawlessly (so far).
Lines 1 and 2 request the bid confirmation screen from ebay with an http fread() command. The page is assigned to a variable.
In line 3, I explode that variable with the separator "key value=". This leaves $key with everything before the tag, and $key with everything following HTML text "key value="
We can forget about $key, it contains the rock fish skeleton. In line 4 we apply the explode() command one more time to $key but this time using the ">" that closes the hidden HTML tag. Voila! we are now left with $clean_key being the buried jem needed to make the cniper.com site work it's magic.
To send bids, we construct the appropriate HTTP call with the variables retrieved from ebay's servers and wham! bids are placed while you sleep. PHP rocks!