cUrl problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • csteimonts
    New Member
    • Mar 2008
    • 1

    #1

    cUrl problem

    Hey there, if it would be possible, since you have figured out the login function of logging into yahoo from PHP CURL, could you post that solution? I'm having quite a time figuring that out.........

    here is my code:
    [php]
    <?

    $c=curl_init();
    curl_setopt($c, CURLOPT_USERAGE NT, "BiogetBot" );
    curl_setopt($c, CURLOPT_RETURNT RANSFER, TRUE);
    curl_setopt($c, CURLOPT_FOLLOWL OCATION, TRUE);
    curl_setopt($c, CURLOPT_HTTPAUT H, CURLAUTH_ANY);
    curl_setopt($c, CURLOPT_HEADER , TRUE);
    curl_setopt($c, CURLOPT_COOKIEJ AR, dirname(__FILE_ _).'/cookie.txt');
    curl_setopt($c, CURLOPT_COOKIEF ILE, dirname(__FILE_ _).'/cookie.txt');
    curl_setopt($c, CURLOPT_URL, "https://login.yahoo.com ");
    $html=curl_exec ($c);
    curl_close($c);
    unset($c);

    ////////////
    // Get URL
    //
    preg_match("/action=\"([\S]*)\" /", $html, $action);
    $url = $action[1];

    ///////////////////////
    // Get Params to pass
    //
    preg_match_all( "/<input type=\"hidden\" name=\"(.*)\" value=\"(.*)\">/", $html, $hidden_vars);

    $params = array();

    foreach($hidden _vars[1] as $index => $name)
    $params[$name] = $hidden_vars[2][$index];

    $params['.done'] = "http://basketball.fant asysports.yahoo .com/nba/38554";
    $params['.persistent'] = "y";
    $params['.save'] = "Sign In";
    $params['login'] = $user;
    $params['passwd'] = $pass;

    $c=curl_init();
    curl_setopt($c, CURLOPT_USERAGE NT, "BiogetBot" );
    curl_setopt($c, CURLOPT_RETURNT RANSFER, TRUE);
    curl_setopt($c, CURLOPT_FOLLOWL OCATION, TRUE);
    curl_setopt($c, CURLOPT_HTTPAUT H, CURLAUTH_ANY);
    curl_setopt($c, CURLOPT_HEADER , TRUE);
    curl_setopt($c, CURLOPT_COOKIEJ AR, dirname(__FILE_ _).'/cookie.txt');
    curl_setopt($c, CURLOPT_COOKIEF ILE, dirname(__FILE_ _).'/cookie.txt');
    curl_setopt($c, CURLOPT_URL, $url);
    curl_setopt($c, CURLOPT_POST, TRUE);
    curl_setopt($c, CURLOPT_POSTFIE LDS, implode("&", $params));
    $html=curl_exec ($c);
    curl_close($c);

    ?>[/php]


    THANKS!

    You must enclose all code within the appropriate code tags!! Read the Posting Guidelnes on that. - moderator
    Last edited by ronverdonk; Mar 4 '08, 11:42 PM. Reason: code tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This thread has been split of because you were hijacking another thread!! That is strictly forbidden, see the Posting Guidelines.

    Also, enclose any code you show within the appropriate coding tags.

    moderator

    Comment

    Working...