SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot Makavely's Avatar
    Join Date
    Jul 2004
    Location
    Romania
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question read https pages

    hi

    Does anyone know how to read a HTTPS page from php? I've try a lot of functions that use fsockopen() but nothing that work.


    thx

  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look at the curl functions:

    http://ca.php.net/curl
    Reduce or eliminate spam on your sites without CAPTHCAs
    - maybe it is possible: http://formantispam.thekerrs.ca/

  3. #3
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using
    Code:
    file_get_contents("ssl://www.somesite.com/somepage.php");

  4. #4
    SitePoint Zealot Makavely's Avatar
    Join Date
    Jul 2004
    Location
    Romania
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mrwooster the funtion doesn't work. It says:

    failed to open stream: Invalid argument

    But the url si correct. I've check it 10 times.

  5. #5
    SitePoint Evangelist mrwooster's Avatar
    Join Date
    Jan 2006
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry - think I got mixed up - try using https:// not ssl:// (ssl:// is for fsockopen) try
    Code:
    <?php 
    file_get_contents("https://www.somesite.com/somepage.php");
    ?>

  6. #6
    SitePoint Zealot Makavely's Avatar
    Join Date
    Jul 2004
    Location
    Romania
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    same error

  7. #7
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Belgian in Mexico
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should really try with CURL. I had the same problem, and discovered it couldn't be done with https, given my PHP config (with openssl as shared module).
    In fact hoped to find an answer to my problem in this post (I didn't found the complete solution, but at least found out about CURL ).
    After some research and testing, I could have it working. Try this code:
    PHP Code:
    $url 'https://www.domain.com/page.html';
    // create a new curl resource
    $ch curl_init();
    // set URL and other appropriate options
    curl_setopt($chCURLOPT_URL$url);
    curl_setopt($chCURLOPT_HEADER0);
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    // grab URL and pass it to the browser
    curl_exec($ch);
    if (
    curl_errno($ch)) {
    print 
    curl_error($ch);
    } else {
    // close curl resource, and free up system resources
    curl_close($ch);

    Note: don't forget to enable CURL in your php.ini file, if it's not already done.

    Hope that helps,

    MichaŽl
    MichaŽl Niessen
    http://assemblysys.com
    (Countries/states/cities with latitude & longitude,
    weathercodes & topical databases)

  8. #8
    SitePoint Zealot Makavely's Avatar
    Join Date
    Jul 2004
    Location
    Romania
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx now i can see the page..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •