Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > PHP: Сеть > Загрузка на фпйлообменник с помощью Curl


Автор: steel1945 4.9.2010, 20:04
Здравствуйте. Есть скрипт для мультизагрузки на обменники,и для него никак не получается на писать плагин для turbobit.net
Код

$debug='';
    $file_loc = 'uploads/' . $info['name'];
    $url = 'http://turbobit.net/';
    
    if($acc and $user and $pwd)
    {
      $loginurl='http://turbobit.net/user/login';
      $loginpost='user%5Blogin%5D='.$user.'&user%5Bpass%5D='.$pwd.'&user%5Bmemory%5D=on&user%5Bsubmit%5D=%D0%92%D0%BE%D0%B9%D1%82%D0%B8';
      $ch = curl_init ();
      curl_setopt ($ch, CURLOPT_URL, $loginurl);
      curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
      curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
      curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookies/');
      curl_setopt ($ch, CURLOPT_POST, 1);
      curl_setopt ($ch, CURLOPT_POSTFIELDS, $loginpost);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
      $result = curl_exec ($ch);
      preg_match('#uploadfile&userId=(.*?)"#is', $result, $aMatches);
      $iUserID = $aMatches[1];
    }
    $postcontent['Filedata'] = '@'.$file_loc;
    $postcontent['id'] = 'null';
    $postcontent['user_id'] = $iUserID;
    $postcontent['stype'] = 'null';
    $postcontent['apptype'] = 'fd1';
    $postcontent['Upload'] = 'Submit Query';
    $ch =$ch? $ch:curl_init ();
    curl_setopt ($ch, CURLOPT_URL, 'http://s38.turbobit.ru/uploadfile');
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt ($ch, CURLOPT_USERAGENT, 'Shockwave Flash');
    curl_setopt ($ch, CURLOPT_POST, 1);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $postcontent);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec ($ch);
    preg_match('#http://turbobit.net/[^\']+#is',$result,$dll);

Никак не пойму где ошибка. Буду премного благодарен за помощь

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)