Here's something to try. Use Chrome in Developer mode and see what headers are being sent. I suspect you will see at least 2 additional HTTP request headers that your script is not sending.
Your script sending neither the 'Host' nor 'User-Agent' Request Headers. Try adding those in with some valid values (IP is specific to the script you posted)...