Need help with Curl ???

Discussion in 'PHP' started by picos, Feb 1, 2010.

  1. #1
    Hello
    I need help very urgent !
    this is my code
    
    $url = 'https://api.libertyreserve.com/xml/balance.aspx';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    
    if(curl_exec($ch) === false)
    {
        echo 'Curl error: ' . curl_error($ch).'|'.curl_errno($ch);
    }
    else
    {
        echo 'Operation completed without any errors'.curl_errno($ch);
    }
    curl_close($ch);
    
    PHP:
    when i run this code, it return an error:
    Curl error: SSL read: error:00000000:lib(0):func(0):reason(0), errno 0|52
    PHP:
    Can someone please help me to fix this code ???
    I try but it did not work
    Thank you very much
     
    picos, Feb 1, 2010 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    Put the url in the constructor.
    $ch = curl_init('https://api.libertyreserve.com/xml/balance.aspx'); // discard $url and curl_setopt($ch, CURLOPT_URL, $url);

    Try set CURLOPT_SSL_VERIFYPEER to FALSE instead of 0.
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    Also a user agent may or may not help.
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0");

    If all fails, your curl wasn't compiled with openssl.
     
    Kaizoku, Feb 1, 2010 IP
  3. picos

    picos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #3
    Hurayyyyy ! Thank you very very very much ! It is working now !
    this is code:
    
    $ch = curl_init('https://api.libertyreserve.com/xml/balance.aspx');
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0");
    if(curl_exec($ch) === false)
    {
        echo 'Curl error: ' . curl_error($ch).'|'.curl_errno($ch);
    }
    else
    {
        echo 'Operation completed without any errors'.curl_errno($ch);
    }
    curl_close($ch);
    
    PHP:
     
    picos, Feb 1, 2010 IP