Реклама - здесь может быть Ваша реклама, которую увидят 4000+ человек в сутки. Хотите 1000 посетителей на свой сайт за 50 копеек?
Главная
Примеры PHP Примеры JavaScript Примеры Ajax Примеры CSS,HTML

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


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

 search="Word"
 xmlhttp.open("POST", "http://api.google.com/search/beta2",true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
   alert(xmlhttp.responseText)
  }
 }
 xmlhttp.setRequestHeader("Man", "POST http://api.google.com/search/beta2 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="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">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>'+
      '</ns1:doGoogleSearch>'+
    '</SOAP-ENV:Body></SOAP-ENV:Envelope>')

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!"

Компьютерные курсы web дизайн. Компьютерные курсы и Web-дизайн.
- Отдых на Мальдивах-проверено: отдых на Мальдивах. - энергосберегающие лампы от производителя, энергосберегающие лампы цена в санкт-петербурге
- Для Вашего строительства профнастил с 8 в любом количестве

© Copyright 2008-2012 by KDG