CURL

Discussion in 'PHP' started by DVMade, 27 Feb 2011.

  1. DVMade

    DVMade Banned

    Joined:
    23 Jul 2010
    Messages:
    110
    Likes Received:
    3
    Reputations:
    0
    Помогите разобраться со скриптом, скрипт писал я, не могу понять почему не работает! Значит пишу вот такой вот скриптик, где ошибки подскажите?
    Code:
    <? function post_content ($url,$postdata) {   $uagent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";    $ch = curl_init( $url );   curl_setopt($ch, CURLOPT_URL, $url);   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   curl_setopt($ch, CURLOPT_HEADER, 0);   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);   curl_setopt($ch, CURLOPT_ENCODING, "");   curl_setopt($ch, CURLOPT_USERAGENT, $uagent);   curl_setopt($ch, CURLOPT_TIMEOUT, 120);   curl_setopt($ch, CURLOPT_FAILONERROR, 1);   curl_setopt($ch, CURLOPT_AUTOREFERER, 1);   curl_setopt($ch, CURLOPT_POST, 1);   curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);    $content = curl_exec( $ch );   $err     = curl_errno( $ch );   $errmsg  =curl_error( $ch );   $header  = curl_getinfo( $ch );   curl_close( $ch );    $header['errno']   = $err;   $header['errmsg']  = $errmsg;   $header['content'] = $content;   return $content; }  $url='http://sendsms.owap.biz/'; $postdata="tel=7**********&pass=******';"; $html=post_content ($url,$postdata);    $ch = curl_init();   curl_setopt($ch, CURLOPT_URL, "http://sendsms.owap.biz/send.php?tel=**********&pass=******&phone=9281896078&from=qChat&text=Test");   curl_setopt($ch, CURLOPT_HEADER, false);   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)');   $data = curl_exec($ch);   curl_close($ch);    ?>
     
  2. LStr1ke

    LStr1ke Elder - Старейшина

    Joined:
    29 Jul 2009
    Messages:
    800
    Likes Received:
    145
    Reputations:
    73
    Оформи код почитабельней. Засунь в тэг
    PHP:
     
  3. SHiNiGaMi

    SHiNiGaMi Banned

    Joined:
    3 Jan 2010
    Messages:
    382
    Likes Received:
    55
    Reputations:
    15
    PHP:
    <?php
    function post_content($url,$postdata)
    {
        
    $uagent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
        
    $ch curl_init$url );
        
    curl_setopt($chCURLOPT_URL$url);
        
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
    curl_setopt($chCURLOPT_HEADER0);
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt($chCURLOPT_ENCODING"");
        
    curl_setopt($chCURLOPT_USERAGENT$uagent);
        
    curl_setopt($chCURLOPT_TIMEOUT120);
        
    curl_setopt($chCURLOPT_FAILONERROR1);
        
    curl_setopt($chCURLOPT_AUTOREFERER1);
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($chCURLOPT_POSTFIELDS$postdata);
        
    $content curl_exec$ch );
        
    $err curl_errno$ch );
        
    $errmsg  =curl_error$ch );
        
    $header  curl_getinfo$ch );
        
    curl_close$ch );

        
    $header['errno'] = $err;
        
    $header['errmsg']  = $errmsg;
        
    $header['content'] = $content;
        return 
    $content;
    }

    $url='http://sendsms.owap.biz/';
    $postdata="tel=7**********&pass=******';";
    $html=post_content($url,$postdata);
    $ch curl_init();
    curl_setopt($ch,CURLOPT_URL,"http://sendsms.owap.biz/send.php?tel=**********&pass=******&phone=9281896078&from=qChat&text=Test");
    curl_setopt($chCURLOPT_HEADERfalse);
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    curl_setopt($chCURLOPT_CONNECTTIMEOUT30);
    curl_setopt($chCURLOPT_USERAGENT'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)');
    $data curl_exec($ch);
    curl_close($ch);
    ?>
    Что в ошибках пишет?
    З.Ы. pass=******';"; - там апостроф и ' не лишние?
    З.Ы.Ы. все-таки скрипт скопипастил)) http://parsing-and-i.blogspot.com/2009/10/curl-post.html
     
    #3 SHiNiGaMi, 27 Feb 2011
    Last edited: 27 Feb 2011
  4. DVMade

    DVMade Banned

    Joined:
    23 Jul 2010
    Messages:
    110
    Likes Received:
    3
    Reputations:
    0
    Как ни странно в ошибки ни чего не выдает! Просто тупо пустая страница! '; действительно было лишние убрал
     
  5. DVMade

    DVMade Banned

    Joined:
    23 Jul 2010
    Messages:
    110
    Likes Received:
    3
    Reputations:
    0
    Вопрос закрыт, всё сделал сам =)