1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

file_get_contents returns error when using https://

Discussion in 'PHP' started by piniyini, Sep 8, 2005.

  1. #1
    How can I avoid this error
    [B]Warning[/B]: file_get_contents(): SSL: fatal protocol
    Code (markup):
    is there something else I can use instead? The script brings up the correct information though
     
    piniyini, Sep 8, 2005 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do a string search in your $url first and if it contains HTTPS skip it.
     
    T0PS3O, Sep 8, 2005 IP
  3. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #3
    that would be one way to avoid the error, but I want to use https! Maybe I will just replace the error so it doesnt show up
     
    piniyini, Sep 8, 2005 IP
  4. retSaMbew

    retSaMbew Banned

    Messages:
    739
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #4
    don't know if this will work - but maybe you could try fsockopen - fwrite - fgets combination for this url instead?

    check out the example here - http://www.php.net/function.fsockopen

    Most likely the port will be 443 though.

    Please let me know if this works after you've tried it
     
    retSaMbew, Sep 8, 2005 IP
  5. retSaMbew

    retSaMbew Banned

    Messages:
    739
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Just found a little note at php.net - "As of PHP 4.3.0, if you have compiled in OpenSSL support, you may prefix the hostname with either 'ssl://' or 'tls://' to use an SSL or TLS client connection over TCP/IP to connect to the remote host. "

    My assumption is that maybe the solution could be

    $host = 'ssl://hostname.com';
    $path = 'file1.php';
    $fp = fsockopen($host,443); 
    fputs($fp,"GET $path HTTP/1.1\r\n"); 
    fputs($fp,"Host: $host\r\n\r\n"); 
    while(!feof($fp)){ 
    echo fgets($fp,1024); 
    fclose($fp);
    PHP:
    please tell me if that works
     
    retSaMbew, Sep 8, 2005 IP
    Willy likes this.
  6. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #6
    Nah, I couldnt get it to work. I will probably str_replace it
     
    piniyini, Sep 8, 2005 IP
  7. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #7
    Yeah... your version of PHP needs to be specifically compiled to support https... if you have the curl extensions installed in your PHP, you could try to use that instead.
     
    digitalpoint, Sep 8, 2005 IP
  8. retSaMbew

    retSaMbew Banned

    Messages:
    739
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #8
    does php4 not support https by defaul?
     
    retSaMbew, Sep 14, 2005 IP
  9. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #9
    digitalpoint, Sep 14, 2005 IP