How to login to Yahoo Account?

Help
waleed
2004-02-17
2004-02-26
  • waleed
    waleed
    2004-02-17

    I have viewed all the messages on the forum, but have been unable to correctly code SNOOPY to allow me to login to my Yahoo account.

    I want to display my Stocks Portfolio on my site.

    I wanted to login to yahoo, go to portfolio page, then display this (in read-only mode).

    Any help or sample code would be greatly appreciated. Thanks

     
    • Joel Nothman
      Joel Nothman
      2004-02-26

      I'm trying to do something similar and have so far written something, but when I try it tells me the client is not accepting cookies, but I can see that it has accepted some! And no, it doesn't require javascript or anything... Either way it's a bit of a slow process that might not be worth it....
      I can get yahoogroups to login in Opera with or without Javascript; with or without referrer logging; but not without cookies. And yet Snoopy seems to work with cookies!

      <?php
      $client = new Snoopy();
      $client->agent = SOME_UA_STRING;

      $client->fetch('https://login.yahoo.com');

      $doc1 = $client->results;

      preg_match('/<form.*action="([^"]*)"/', $doc1, $res);
      print_r($res);
      print($res[1][0]."\n");
      $submit_url = $res[1];
      preg_match_all('/<input[^>]*>/',$doc1, $form1);

      $vars = array();
      foreach($form1[0] as $input) {
          preg_match('/name="([^"]*)"/', $input, $res);
          $name = $res[1];
          preg_match('/value="([^"]*)"/', $input, $res);
          $value = $res[1];
          if(!isset($value)) {
              preg_match('/value=([^ >]*)/', $input, $res);
              $value = $res[1];
          }
          $vars[$name] = $value;
      }

      $vars['login'] = 'login';
      $vars['passwd'] = 'pwd';
      $vars['.persistent'] = 'y';

      $client->submit($submit_url, $vars);

      ?>