PEAR::SOAP_Client, Google API

From: Adam I Agnieszka Gasiorowski Fnord (agquarx_at_venus.ci.uw.edu.pl)
Date: 11/28/03


Date: Fri, 28 Nov 2003 16:54:53 +0100
To: Lista PHP General <php-general@lists.php.net>



        I'm trying to get ANYTHING out of google
 API (for now), but it doesn't let me. I use
 the SOAP_Client from PEAR project and the WDSL
 file you get from Google when you register your
 key for using with their API.

        When I give an action wrong parameters,
 everything works great, it complaints that
 I gave it wrong data. I provide RIGHT data
 then and...I get a blank screen. No errors in
 logs, no nothing. What can be wrong? All I
 did to downloaded from PEAR files was to change
 include paths so I could place all the required
 files in one directory (SOAP).

        The short test code follows (as you
 can see I tried the doGoogleSearch action,
 defined in the WDSL, too). It looks like it
 bombs even before the first echo...:

        Help me, I'm really depressed and
 frustrated now :8[. I hate it when it doesn't
 give any kind of feedback like this...

<?
require_once('SOAP/Client.php');
$key = 'my google key goes here';
$queryterms = 'marichuana';
/*
$query = array(
                'key' => $key,
                'q' => $queryterms,
                'start' => 0,
                'maxResults' => 10,
                'filter' => true,
                'restrict' => '',
                'safeSearch' => false,
                'lr' => '',
                'ie' => '',
                'oe' => ''
              );
*/
$query = array(
                'key' => $key,
                'phrase' => $queryterms
              );
$soapclient = new SOAP_Client('GoogleSearch.wsdl', true);
$result = $soapclient -> call('doSpellingSuggestion', $query);
echo '<pre>' . print_r($result, TRUE) . '</pre>';
$i = 1;
print("Top 10 results for <strong>$queryterms</strong><br /><br />");
foreach ($result as $key => $value)
{
  if($key == 'resultElements')
  {
    foreach ($value as $key2 => $value2)
    {
      foreach($value2 as $key3 => $value3)
      {
        if($key3 == 'URL')
        {
          $snippet = substr(strip_tags($value2["snippet"]), 0, 70);
          $summary = substr($value2["snippet"], 0, 70);
          $title = substr(strip_tags($value2["title"]), 0, 70);
          $cachedSize = $value2["cachedSize"];
          print("#$i: <strong><a href=\"$value3\">$title</a></strong><br />Summary: $summary<br />$value3 - $cachedSize<hr />");
          $i++;
        }
        print("$key3 $value3<br>");
      }
    }
  }
  print("Key: $key; Value: $value<br>\n");
}
?>

-- 
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info  { iWanToDie }   WiNoNa    )   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne kształty... http://www.opera.com 007




Relevant Pages

  • Commercial use of Google API
    ... I am slowly learning about this Google API thing; ... "Unauthorized" SEO software that violates Google's Terms & ... SEO software the *does* use the Google API - but as an SEO selling ...
    (alt.internet.search-engines)
  • Re: Spidering Hacks
    ... The same place you'd look to use their API from Ruby, Python, etc. ... My point was that the question in *this* thread has nothing to do with Perl. ... Ruby, Python, C, Java, or any other programmers all obtain their Google keys ...
    (comp.lang.perl.misc)
  • Re: Spreadsheet translation
    ... Dim URL As String ... You send an XML message containing your API request in javascript to the ... Information of the google translate API can be found here: ...
    (microsoft.public.excel.programming)
  • Re: Spreadsheet translation
    ... the API is not a Win32 dll. ... It is a web service hosted by google. ... send an XML message containing your API request in javascript to the google ... Information of the google translate API can be found here: ...
    (microsoft.public.excel.programming)
  • Re: CW X 10.1++ ... lets start a pool
    ... I use Google to search for Mac OS X APIs on a regular basis. ... Blah blah blah. ... API is pretty specific in terms of defining a search. ... be a need for documentation that isn't based on searching. ...
    (comp.sys.mac.programmer.codewarrior)