Supportnet Computer
Planet of Tech

Supportnet / Forum / Skripte(PHP,ASP,Perl...)

[file_get_contents]: failed to open stream





Frage

Hallo, Habe folgendes Problem: I want to include the googleSearch into my wiki. Therefore I use the following implementation for mediawiki: [code] <?php # Created by Matt Hart, Intuit, Inc. http://meta.wikimedia.org/wiki/User:MHart # Note that this is not really an extension in the scrict sense - it isn´t added # to the extensions list and such. Rather it replaces the search. function wfGoogleSearch( $par=´´ ) { global $wgRequest, $wgUser; global $wgOut, $wgSitename; global $wgScriptPath; $searchPage = new SpecialSearch( $wgRequest, $wgUser ); $search = $wgRequest->getText( ´search´, $par ); $start = $wgRequest->getText( ´start´, $par); $wgOut->setPageTitle($search . " - Google Search"); $sitesearch = urlencode($_SERVER["HTTP_HOST"] . $wgScriptPath); # Google URL Parameters # site=ext_name : this is the Google appliance (GA) "collection" to search # client=name : this is the GA client that is allowed to make requests # as_sitesearch= : this restricts the results to this specific wiki, even on shared domains # so wikis.intuit.com/first gets its own results # likewise wikis.intuit.com/second gets its own $url = ´http://googlesearchurl.yoursite.com/search?q=´ . urlencode($search) . ´&output=xml&site= ext_name&client=name&as_sitesearch=´ . $sitesearch . ´&start=´ . $start; $xmldata = file_get_contents($url); # This saves the file to a temp location so that XSLTPROC can # run on it. If you have Sablotron installed with PHP 5, you can # use it´s XSLT functions. The following method, however, works with # any version of PHP. $xmlfile = tempnam("",""); $file = fopen($xmlfile,"w"); fwrite($file,$xmldata); fclose($file); $results = xsltproc(´extensions/Google.xslt´,$xmlfile); $wgOut->addHTML($results); unlink($xmlfile); $wgOut->output(); return; } function xsltproc($xslfile, $xmlfile) { $toexec = "xsltproc " . $xslfile . " " . $xmlfile; exec($toexec,$results); return implode("",$results); } ?> [/code] For the url: googlesearch.yoursite.com I use my local directory, where I am testing my extension: http://localhost/wiki/index.php/ If i am now testing this extension, searching for a word, there will appear the following fault:[file_get_contents]: failed to open stream: HTTP request failed! Can you help me? I´m disappointed that i cannot correct the mistake by my own.. mit freundlichen Grüßen, Daniel ------------------ XAMPP 1.5.3a PHP 5.1.4 Apache 2.2.2 Mysql 5.0.21

Antwort 1 von Newan

Lass dir mal die variable $url ausgeben und versuche diesen string in einem broserfenster einzutragen. Und schau dann ob da was kommt!

Ich möchte kostenlos eine Frage an die Mitglieder stellen:


Ähnliche Themen:


Suche in allen vorhandenen Beiträgen: