help post form with curl + php

Discussion in 'PHP' started by zappak, Mar 17, 2011.

  1. #1
    i'm trying to post data but not able to do..

    it's showing "Bad referer" .. don't know what's the prob exactly and what does that mean..

    my code
    <?php
    
    $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, 'http://3.ly/');
              curl_setopt($ch, CURLOPT_POSTFIELDS,"u=http%3A%2F%2Fgoogle.com&x=15&y=13&u_id=&token=1cbff13c3d6d875f43fede31b99c0574");          
              curl_setopt($ch, CURLOPT_POST, 1);
              curl_setopt($ch, CURLOPT_HEADER, 0);
              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
              curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
              curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12");
              $data = curl_exec($ch);
              curl_close($ch);
              echo $data;
            
     
     
     ?>
    PHP:
    anyone think what's exactly prob is??
     
    zappak, Mar 17, 2011 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Add the following option:

    
    <?php
    curl_setopt ($ch, CURLOPT_REFERER , 'http://3.ly');
    
    PHP:
     
    ThePHPMaster, Mar 17, 2011 IP
  3. zappak

    zappak Active Member

    Messages:
    366
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    80
    #3
    wow.. that's worked..

    thx a lot mate.. :)


     
    zappak, Mar 17, 2011 IP