note 64788 added to function.file-get-contents

From: Date: Thu, 20 Apr 2006 17:56:35 +0000
Subject: note 64788 added to function.file-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-108833@lists.php.net to get a copy of this message
Google Web API connection with file_get_contents. Using DOM you can change the search word. <?php $soap=domDocument::load("soap.xml"); $content=$soap->saveXML(); $options = array( 'http'=>array( 'method' => 'POST', 'header' => "Accept-Encoding: gzip, deflate\nContent-Type: text/xml;". "charset=utf-8\nContent-length: ".strlen($content)."\n", 'content' => $content ) ); $context=stream_context_create($options); $result=file_get_contents('http://api.google.com/search/beta2', false,$context); //Display Google response header("Content-type: text/xml"); echo $result; die(); ?> soap.xml: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <key xsi:type="xsd:string">XXXXXXXXXXX</key> <q xsi:type="xsd:string">olpc</q> <start xsi:type="xsd:int">0</start> <maxResults xsi:type="xsd:int">10</maxResults> <filter xsi:type="xsd:boolean">true</filter> <restrict xsi:type="xsd:string"></restrict> <safeSearch xsi:type="xsd:boolean">false</safeSearch> <lr xsi:type="xsd:string"></lr> <ie xsi:type="xsd:string">latin1</ie> <oe xsi:type="xsd:string">latin1</oe> </ns1:doGoogleSearch> </SOAP-ENV:Body> </SOAP-ENV:Envelope> ---- Server IP: 192.35.244.50 Probable Submitter: 80.109.11.235 ---- X-Spam-Status: No, hits=3.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_20_30 autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php Edit -- http://master.php.net/note/edit/64788 Del: integrated -- http://master.php.net/note/delete/64788/integrated Del: useless -- http://master.php.net/note/delete/64788/useless Del: bad code -- http://master.php.net/note/delete/64788/bad+code Del: spam -- http://master.php.net/note/delete/64788/spam Del: non-english -- http://master.php.net/note/delete/64788/non-english Del: in docs -- http://master.php.net/note/delete/64788/in+docs Del: other reasons-- http://master.php.net/note/delete/64788 Reject -- http://master.php.net/note/reject/64788 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#108833) next »