note 64788 deleted from function.file-get-contents by bjori
| From: | bjori@php.net | Date: | Thu, 20 Apr 2006 18:32:46 +0000 |
| Subject: | note 64788 deleted from function.file-get-contents by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108841@lists.php.net to get a copy of this message | ||
Note Submitter: bz at datenkueche dot com
----
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>