Twitter Error 417 – Expectation Failed: PHP Solution

By | June 28, 2011

Recently I had to deal with Twitter avatar upload for a Twitter application. Everything went very well, but when I have prepared everything for the upload query, the only server response I got was Error 417.

Since I used cURL, I tried to deal with different headers, but with no luck at all. I found the solution at MSDN website. The correct string is:

curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Expect:’));

You need to add it to your cURL block. This issue is related to Twitter only; I have no idea why they decided to accept only blank Expect header. Hope it saves you some time.