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.

Bookmark: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Related Posts:

This entry was posted in PHP, Tutorial. Bookmark the permalink.

3 Responses to 417 status/response code and PHP cURL

  1. Great works, keep it up.

    [Reply]

  2. invarbrass says:

    cURL or lighttpd is not at fault here. It’s the way the HTTP protocol was designed.

    To understand what the “Expect: 100- continue” header line does, please refer to RFC 2616:
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

    [Reply]

  3. Alwahsh says:

    thanks for that

    [Reply]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">