Need help adding Google's Nofollow Tag

Discussion in 'PHP' started by Farmer77, Sep 9, 2009.

  1. #1
    I want to embed rss news on my site so I found a feed aggregator. I inputted the RSS feeds I wanted and it spit this code out for me to paste on my page:

    
    <?php
    $ch = curl_init();
    $timeout = 5; // in seconds, you can change this lower if you want
    curl_setopt ($ch, CURLOPT_URL, 'http://myfeed.com/example.html');
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);
    curl_close($ch);
    echo $file_contents;
    ?> 
    
    Code (markup):
    I want to put a nofollow tag to the feeds that will get displayed. What do I have to change in this code?
     
    Farmer77, Sep 9, 2009 IP
  2. innovatewebs

    innovatewebs Well-Known Member

    Messages:
    194
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    Hi
    I have more then 4 year exp in php. I can help you.
    I have exp in reading RSS.
     
    innovatewebs, Sep 9, 2009 IP
  3. Farmer77

    Farmer77 Peon

    Messages:
    232
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm not looking to pay someone. I'll just put nofollow in a metatag if no one can help but would prefer if it can be done through that specific code.
     
    Farmer77, Sep 9, 2009 IP
  4. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Would adding something like:

    
    str_replace("<a", "<a rel=\"nofollow\"", $file_contents);
    
    
    PHP:
    It replaces all the instances of <a in the text with <a rel="nofollow"
     
    wd_2k6, Sep 9, 2009 IP
    Farmer77 likes this.
  5. Farmer77

    Farmer77 Peon

    Messages:
    232
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you wd_2k6, that small piece of code works. I'll leave it here so that people who are looking to put a nofollow tag or another microformat into a php curl script feed can find it on the search engines.

    Rep +1

    
    <?php
    $ch = curl_init();
    $timeout = 5; // in seconds, you can change this lower if you want
    curl_setopt ($ch, CURLOPT_URL, 'http://thefeed.com/example.html');
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);
    $file_contents = str_replace("<a", "<a rel=\"nofollow\"", $file_contents);
    curl_close($ch);
    echo $file_contents;
    ?>
    
    
    Code (markup):
     
    Farmer77, Sep 10, 2009 IP