AAA Главная
Примеры PHP Примеры JavaScript Примеры Ajax Примеры CSS,HTML

Использование API Google

Для выполнения до 1000 XML запросов к Google в день Вам предварительно необходимо зарегистрироваться и получить ключ.

 search="Word""POST", "",true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
 xmlhttp.setRequestHeader("Man", "POST HTTP/1.1")
 xmlhttp.setRequestHeader("MessageType", "CALL")
 xmlhttp.setRequestHeader("Content-Type", "text/xml")

 xmlhttp.send("<?xml version='1.0' encoding='UTF-8'?>"+"\n\n"+"<SOAP-ENV:Envelope"+
      ' xmlns:SOAP-ENV=""'+
      ' xmlns:xsi=""'+
      ' xmlns:xsd="">'+
      ' xmlns:ns1="urn:GoogleSearch"'+
      ' SOAP-ENV:encodingStyle="">'+
      '<key xsi:type="xsd:string">GOOGLEKEY</key> <q'+
      ' xsi:type="xsd:string">'+search+'</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>'+

Google is using a SOAP interface, many people think SOAP has some serious issues worth considering. REST is probably a better model as it works with the current web framework, proxies, caches etc. So whilst we can use the XML HTTP Request object to talk soap, it's probably best not to unless you have no control over what's happening on the server end.

By default the object can only call back to the same server, in a reduced security environment (accessed from file:// say) IE can access any domain, Mozilla can also do that if you request and are granted the appropriate permissions see "a google thread I can't get to offline!"


© Copyright 2008-2020 by KDG

Rambler's Top100