Check partners Site for your Link ?

Discussion in 'PHP' started by MSK7, Jun 8, 2009.

  1. #1
    Hello all,

    I want to create a system that I will place in my admin where

    I go and check my partners Site that my website LINK is still

    there on his website or not .

    As on google search i found maximum ready made softwares

    for these purpose.

    Is there any particular tutorial or examples regarding these ?

    please suggest me , How these can be achieved using php.


    any suggestion will be appreciated.


    Thanks & Regards.
     
    MSK7, Jun 8, 2009 IP
  2. HorseGalleria

    HorseGalleria Peon

    Messages:
    91
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could use file_get_contents() and specify the URL where the link should be located. The function returns a string. So, just search the string for your link.
     
    HorseGalleria, Jun 8, 2009 IP
  3. MSK7

    MSK7 Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Hello HorseGalleria ,


    Thanks for your precious suggestion.

    on searching info about the function file_get_contents() suggested by you

    i found a function curl_init();

    suggested in an article -

    http://eight7teen.com/articles/convert-your-file_get_contents-commands-to-curl/

    using that a little bit my code works, but always message for No link exists,

    But actually the link already exists there on partners site .

    i think i am wrong at the point of my link matching in the code.

    anyway here is my few code :

    
    
    <?php
     
    //Initialize the Curl session
    $ch = curl_init();
    
    
    //Create a variable with the URL you want to "get".
    $URL = "http://www.mypartnersite.com/linkpage/";
    
    
    //Set curl to return the data instead of printing it to the browser.
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    
    //Set the URL
    curl_setopt($ch, CURLOPT_URL, $URL);
    
    
    //Execute the fetch
    $data_we_got = curl_exec($ch);
    
     
     $my_site = "http://www.mysitename.org/"; 
     
    
    
      if(preg_match('#<a[^>]* href\s*=\s*("|\')'.preg_quote($my_site).'\1[^>]*>#i', $data_we_got))  {
       
    
    
        echo 'Yes, Link Exists .'; 
    	
    	
     }  else  {
    
    
        echo 'No,  Link does not exists .'; 
    	
     }
     
     //Close the connection
    curl_close($ch);
    
    ?>
    
    
    Code (markup):

    please help me to sort out the problem in these code as it always messages

    for Link does not exists , But actually the link exists there.



    Thanks & Regards.
     
    MSK7, Jun 9, 2009 IP
  4. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #4
    curl has no link with file get contents

    you need to use php regular expressions
     
    crivion, Jun 9, 2009 IP