Using CURL to get the HTTP status code of a URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Soper

    Using CURL to get the HTTP status code of a URL

    I would like to get the HTTP status code of a URL using PHP. I think
    CURL is the way to go but I can't see how to do it. I see I can use
    curl_getinfo on the CURL session after I've curl_exec'ed it but I
    can't see what options I should set to get CURL to only get the HTTP
    status code and not retrieve the data at the URL.

    Help gratefully received!

    Thanks,
    Geoff
  • Jochen Daum

    #2
    Re: Using CURL to get the HTTP status code of a URL

    Hi,

    On 29 Mar 2004 03:26:11 -0800, geoff.google.no spam@alphaworks .co.uk
    (Geoff Soper) wrote:
    [color=blue]
    >I would like to get the HTTP status code of a URL using PHP. I think
    >CURL is the way to go but I can't see how to do it. I see I can use
    >curl_getinfo on the CURL session after I've curl_exec'ed it but I
    >can't see what options I should set to get CURL to only get the HTTP
    >status code and not retrieve the data at the URL.[/color]


    I think you want to send a HEAD request.

    www.php.net/curl has heaps of examples, a HEAD request has IMO the
    same structure as a GET request.

    HTH, Jochen
    --
    Jochen Daum - Cabletalk Group Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

    Comment

    • Manuel Lemos

      #3
      Re: Using CURL to get the HTTP status code of a URL

      Hello,

      On 29 Mar 2004 03:26:11 -0800, geoff.google.no spam@alphaworks .co.uk
      (Geoff Soper) wrote:[color=blue]
      >I would like to get the HTTP status code of a URL using PHP. I think
      >CURL is the way to go but I can't see how to do it. I see I can use
      >curl_getinfo on the CURL session after I've curl_exec'ed it but I
      >can't see what options I should set to get CURL to only get the HTTP
      >status code and not retrieve the data at the URL.[/color]

      You may want to try this HTTP client class that lets you do exactly what
      you want.



      --

      Regards,
      Manuel Lemos

      PHP Classes - Free ready to use OOP components written in PHP
      Free PHP Classes and Objects 2025 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


      PHP Reviews - Reviews of PHP books and other products


      Metastorage - Data object relational mapping layer generator

      Comment

      Working...