Jump to content

ryancanulla

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Posts posted by ryancanulla

  1. Hi there,

     

    Any help is greatly appreciated. I've commented out the code giving me trouble.

     

    Error = <br />

    <b>Warning</b>:  curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>34</b><br />

    <br />

    <b>Warning</b>:  curl_setopt(): supplied argument is not a valid cURL handle resource in <b>/###.php</b> on line <b>35</b><br />

     

    <?php
    $ch = curl_init();
    $timeout = 30;
    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    
    if ($_REQUEST['update']) {
    
    curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_USERPWD, $_REQUEST['username'] . ':' . $_REQUEST['password']);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    //curl_setopt($c, CURLOPT_POST, true);
    //curl_setopt($c, CURLOPT_POSTFIELDS, $_REQUEST['update']);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    
    $response = curl_exec($ch);    
    
    if (curl_errno($ch)) {
    	echo curl_error($ch);
    } else {
    	curl_close($ch);
    	echo $response;
    }
    
    }
    

     

  2. Hi there,

     

    I'm using this php proxy with a flex app to get around security issues, and need to authenticate with a username/password to get back my xml.

     

    Anyone know how I could modify this php script to pass in credentials via POST?

     

    <?php
    $ch = curl_init();
    $timeout = 30;
    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    
    curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    
    $response = curl_exec($ch);    
    
    if (curl_errno($ch)) {
        echo curl_error($ch);
    } else {
        curl_close($ch);
        echo $response;
    }
    ?>
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.