I am getting the following error:
getimagesize(https://static1.squarespace.com/static/570d03d02b8dde8b2642afca/570f74e87c65e4819dec6812/57272dbfb6aa606f78a5d8b5/1470397291105/4XTRYCK3.jpg): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
The image opens without problems in my browser.
Does anyone understand why this fails?
Advertisement
Answer
Squarespace is rejecting any connection where the User-Agent header is not a web browser. This includes CURL and getimagesize.
You can set the user-agent header by inserting this into your code:
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)');