PHP help needed to replace old msn search function

Discussion in 'PHP' started by postyman, May 1, 2008.

  1. #1
    I have bought a ebay search script and it includes
    a function to put in search results from msn if no
    ebay results are available.

    The script is obviously out of date as the msn function
    does not work and looks to be old code.

    This is the function part;

    function getMSNResults($searchQuery, $start, $number) {

    $url = "http://beta.search.live.com/results.aspx?q=".urlencode($searchQuery).

    "&first=".$start.

    "&count=".$number.

    "&format=xml&type=images&adlt=off";


    $content = file_get_contents($url);

    preg_match_all("/<documentset source=\"FEDERATOR_MONARCH\" start=\".*?\" count=\".*?\" total=\"(.*?)\" cached=\".*?\"><document><title>/si",$content,$matches);

    $this->numberOfResults = $matches[1][0];


    $content = preg_replace("/&amp;/si","",$content);


    preg_match_all("/<document><title>([^<]*)<\/title><desc>([^<]*)<\/desc><url>([^<]*)<\/url><displayurl>[^<]*<\/displayurl><language>[^<]*<\/language><captionurl>([^<]*)<\/captionurl><\/document>/si",$content,$matches);

    $this->resultsArray['title'] = $matches[1];

    $this->resultsArray['description'] = $matches[2];

    $this->resultsArray['url'] = $matches[3];

    $this->resultsArray['display_url'] = $matches[4];

    Anyone have any idea how to replace with correct code or
    a possible better alternative.

    Any help appreciated.

    Terry
     
    postyman, May 1, 2008 IP