home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 February / PCWorld_2003-02_cd.bin / Komunik / sambar / sambar53b3.exe / sysadmin / control / soap / GOOGLE.ASP next >
Encoding:
Text File  |  2002-11-26  |  2.1 KB  |  73 lines

  1. <HTML>
  2. <HEAD><TITLE>Sambar Server SOAP Control Panel</TITLE>
  3. <% 
  4. #include "../header.asp"
  5. #include "../menu.asp"
  6. area = "google";
  7. #include "submenu.asp"
  8. %>
  9. <BR>
  10. <BLOCKQUOTE><BLOCKQUOTE>
  11. <FORM method=get action=google.asp>
  12. <table border=0 cellspacing=4>
  13. <tr><td>Google Key</td>
  14. <td><INPUT NAME=key size=40 VALUE="<%=findParameter($params, "key", ""); %>"></td></tr>
  15. <tr><td>Query</td>
  16. <td><INPUT NAME=query size=40 VALUE="<%=findParameter($params, "query", ""); %>"></td>
  17. </tr>
  18. <tr><td></td>
  19. <td><INPUT TYPE=submit VALUE="Google Search"></td></tr>
  20. </tr>
  21. </table>
  22. </FORM>
  23. <BR>
  24. <%
  25. key = getParameter($params, "key");
  26. query = getParameter($params, "query");
  27. if ((key != NULL) && (query != NULL))
  28. {
  29.     /*
  30.     ** query Google using their SOAP interface
  31.     */
  32.     $soap = soapService("http://api.google.com/search/beta2", 
  33.         "doGoogleSearch", "GoogleSearch");
  34.     soapPropertySet($soap, "action", "urn:GoogleSearchAction");
  35.     soapParameterAdd($soap, "key", key);
  36.     soapParameterAdd($soap, "q", query);
  37.     soapParameterAdd($soap, "start", 0);
  38.     soapParameterAdd($soap, "maxResults", 10);
  39.     soapParameterAdd($soap, "filter", (boolean)1);
  40.     soapParameterAdd($soap, "restrict", "");
  41.     soapParameterAdd($soap, "safeSearch", (boolean)0);
  42.     soapParameterAdd($soap, "lr", "");
  43.     soapParameterAdd($soap, "ie", "latin1");
  44.     soapParameterAdd($soap, "oe", "latin1");
  45.  
  46.     /* Google failed to implement chunking from the HTTP/1.1 spec.    */
  47.     soapPropertySet($soap, "chunk", "false");
  48.     soapCall($soap);
  49.  
  50.     int time = soapPropertyGet($soap, "msec");
  51.     val = soapResultGet($soap, NULL);
  52.     if (val == NULL)
  53.             printf("doGoogleSearch SUCCESS %d msec\n", time);
  54.     else
  55.             printf("doGoogleSearch FAILURE %d msec\n", time);
  56.  
  57.     soapServiceFree($soap);
  58. }
  59.  
  60. %>
  61. <BR>
  62. Note:  In order to use the Google Web APIs you must first register
  63. with Google to recieve an authentication key.  You can do this online
  64. at <A HREF="http://www.google.com/apis/">http://www.google.com/apis/</A>.
  65. <BR>
  66. Your key will have a limit on the number of requests a data that you
  67. can make.  The default limit is 1000 queries per day.
  68. </BLOCKQUOTE></BLOCKQUOTE>
  69. <%
  70. #include "../footer.asp"
  71. %>
  72. </BODY></HTML>
  73.