417 status/response code and PHP cURL

Recently I have released an extension named put_twitter for PunBB 1.3.x. It sends forum’s activity to designated twitter account. It uses twitter class for posting to twitter which utilizes PHP’s cURL library.

The extension works fine for most of the people. But a few were complaining that it was not working for them! I was totally confused! Today while working with this script, I have tried to know the server’s response. I found that it was returning 417. This is first time in my life getting such response code! So I have started googling! After a long search I have found the solution.

When we prepare cURL request header, we need to add an extra line to get rid of this error. It is like:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:"));

No sooner I added it and uploaded, I found my problem fixed and all messages are not instantly posting to twitter.

More more info please visit this and this.