need help with function get

Discussion in 'PHP' started by DjZoC, Jun 30, 2010.

  1. #1
    hello there,

    if want to take the title from website.com with function get or curl, on his statics to show mywebsite.com (referer) how many times my website take the title from website.com to show referer mywebsite.com

    can someone tell me how i can make this, thanks
     
    DjZoC, Jun 30, 2010 IP
  2. Triggs

    Triggs Active Member

    Messages:
    84
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #2
    Do you mean you want to have a counter of how many times someone clicked a link on website.com to mywebsite.com?
    If so, try this (not tested);

    
    $referrer = $_POST['referrer'];
    if ($referrer == 'website.com'){
        // do some mysql update here.
    }
    
    PHP:
    I'm to lazy to do the MySQL part myself, refer to w3schools ( http://www.w3schools.com/PHP/php_mysql_update.asp )to learn how to work with MySQL.
     
    Triggs, Jul 1, 2010 IP
  3. webal

    webal Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you can chouse curl referer option
     
    webal, Jul 3, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    <?php
          //the site you want to grab the title from...
          $url = "http://website.com";
          
          $referer = "http://mywebsite.com";
          $curl = curl_init();
          curl_setopt($curl, CURLOPT_URL, $url);
          curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
          curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($curl, CURLOPT_AUTOREFERER, false);
          curl_setopt($curl, CURLOPT_REFERER, $referer);
          curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
          $output = curl_exec($curl);
      
          preg_match('~<title>(.+?)</title>~is', $output, $a);
          
          $title = $a[1];
          
          echo $title;
    ?>
    PHP:
     
    danx10, Jul 3, 2010 IP