Page 1 of 2
google API
Posted: Fri Oct 06, 2006 10:37 am
by malcolmboston
i have this code in PHP for getting the results page from google through SOAP
Code: Select all
function getGoogleResults () {
// connect to the soap client
$soapclient = new soapclient("http://api.google.com/GoogleSearch.wsdl","wsdl");
// get back a result
$queryResult = $soapclient->call("doGoogleSearch", $this->searchParameters, "urn:GoogleSearch");
// and on it go's.............................
now ive had this working before but now whenever i send the request i get this cryptic error message:
Code: Select all
Array
(
[faultcode] => SOAP-ENV:Server
[faultstring] => Exception while handling service request: com.google.soap.search.GoogleSearchService.doGoogleSearch([none]) not found.
[faultactor] => /search/beta2
[detail] => Array
(
[stackTrace] => java.lang.NoSuchMethodException: com.google.soap.search.GoogleSearchService.doGoogleSearch([none]) not found.
at org.apache.soap.util.MethodUtils.getEntryPoint(MethodUtils.java:134)
at org.apache.soap.util.MethodUtils.getMethod(MethodUtils.java:548)
at org.apache.soap.util.MethodUtils.getMethod(MethodUtils.java:528)
at org.apache.soap.server.RPCRouter.invoke(RPCRouter.java:114)
at org.apache.soap.providers.RPCJavaProvider.invoke(RPCJavaProvider.java:129)
at org.apache.soap.server.http.RPCRouterServlet.doPost(RPCRouterServlet.java:288)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at com.google.gse.HttpConnection.runServlet(HttpConnection.java:436)
at com.google.gse.HttpConnection.run(HttpConnection.java:376)
at com.google.gse.DispatchQueue$WorkerThread.run(DispatchQueue.java:254)
)
)
does anyone know what it means and / or how to solve it
Posted: Sat Oct 07, 2006 3:54 am
by malcolmboston
*bump
Posted: Sat Oct 07, 2006 4:31 am
by patrikG
you're calling a function that doesn't exist.
Posted: Sat Oct 07, 2006 4:35 am
by malcolmboston
no im not, like i said this exact code worked fine about 2 weeks ago, i actually copied and pasted that element of the code from an existing application i built..... although google can change it at anytime as its in Beta they simply would not change that element as it would likely break thousands of existing applications, in fact my first use of the google API i developed a SEO tool for an old job, i hope it has broke

Posted: Sat Oct 07, 2006 4:37 am
by Ollie Saunders
Why does it say you aren't using any parameters? Could it be that $this->searchParameters is null?
Posted: Sat Oct 07, 2006 5:05 am
by malcolmboston
nope its full, i have a debug mode option in my class that prints out everything... its there and correct
Posted: Sat Oct 07, 2006 6:04 am
by volka
Code: Select all
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$apiKey = '...';
$searchphrase = 'devnet';
$queryResult = $soapclient->doGoogleSearch($apiKey, $searchphrase, 0, 10, False, '', False, '', 'utf-8', "utf-8");
var_dump($queryResult);
?>
Code: Select all
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$params = array(
'key'=>'...',
'q'=>'devnet',
'start'=>0,
'maxResults'=>10,
'filter'=>false,
'restrict'=>'',
'safeSearch'=>false,
'lr'=>'',
'ie'=>'utf-8',
'oe'=>'utf-8'
);
$queryResult = $soapclient->__soapCall('doGoogleSearch', $params);
var_dump($queryResult);
?>
works both fine for me
Posted: Sat Oct 07, 2006 7:27 am
by malcolmboston
still not working, im baffled, ok some code:
Code: Select all
function getGoogleResults () {
// connect to the soap client
$soapclient = new soapclient("http://api.google.com/GoogleSearch.wsdl","wsdl");
// get back a result
$queryResult = $soapclient->call('doGoogleSearch', $this->searchParameters);
if (empty($queryResult)) {
output::outputWarning('API Failure :: Failed to return a resultset'); // output warning and retry
$results = $this->getResults ();
} else {
return $queryResult;
}
}
heres the output
Code: Select all
Array
(
[key] => ****
[q] => Carhartt
[start] => 0
[maxResults] => 10
[filter] => 1
[restrict] =>
[safeSearch] =>
[lr] => lang_en
[ie] => utf-8
[oe] => utf-8
)
Array
(
[faultcode] => SOAP-ENV:Server
[faultstring] => Exception while handling service request: com.google.soap.search.GoogleSearchService.doGoogleSearch([none]) not found.
[faultactor] => /search/beta2
[detail] => Array
(
[stackTrace] => java.lang.NoSuchMethodException: com.google.soap.search.GoogleSearchService.doGoogleSearch([none]) not found.
at org.apache.soap.util.MethodUtils.getEntryPoint(MethodUtils.java:134)
at org.apache.soap.util.MethodUtils.getMethod(MethodUtils.java:548)
at org.apache.soap.util.MethodUtils.getMethod(MethodUtils.java:528)
at org.apache.soap.server.RPCRouter.invoke(RPCRouter.java:114)
at org.apache.soap.providers.RPCJavaProvider.invoke(RPCJavaProvider.java:129)
at org.apache.soap.server.http.RPCRouterServlet.doPost(RPCRouterServlet.java:288)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at com.google.gse.HttpConnection.runServlet(HttpConnection.java:436)
at com.google.gse.HttpConnection.run(HttpConnection.java:376)
at com.google.gse.DispatchQueue$WorkerThread.run(DispatchQueue.java:254)
)
)
One True Saxon
Array
(
[key] => ***
[q] => One True Saxon
[start] => 0
[maxResults] => 10
[filter] => 1
[restrict] =>
[safeSearch] =>
[lr] => lang_en
[ie] => utf-8
[oe] => utf-8
)
Posted: Sat Oct 07, 2006 7:28 am
by volka
did you try
Code: Select all
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$params = array(
'key'=>'...',
'q'=>'devnet',
'start'=>0,
'maxResults'=>10,
'filter'=>false,
'restrict'=>'',
'safeSearch'=>false,
'lr'=>'',
'ie'=>'utf-8',
'oe'=>'utf-8'
);
$queryResult = $soapclient->__soapCall('doGoogleSearch', $params);
var_dump($queryResult);
?>
just for testing purposes?
Is your script running with error_reporting E_ALL?
can't find a second parameter "wsdl" in the
manual.
Posted: Mon Oct 09, 2006 10:48 am
by malcolmboston
ok i got the error message to stop, but now i get a different error message

i cant believe tbh im having this many problems with it, ive done this before without a hitch!!
anyway the error message:
Notice: Undefined index: in C:\netserver\www\labs\gQuery\includes\nusoap.php on line 5901
That nusoap file is an absolutely unedited file, total lines is 7241
the code the error is referring to in Nusoap is
Code: Select all
// the next line is line "5899"
$this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
// get final value
$this->soapresponse = $this->message[$this->root_struct]['result'];
// get header value: no, because this is documented as XML string
// if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
// $this->responseHeaders = $this->message[$this->root_header]['result'];
// }
im so baffled my brain is hurting, any ideas anyone?
Posted: Mon Oct 09, 2006 11:01 am
by malcolmboston
also when i run this code which was kindly provided by Volka...
Code: Select all
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$params = array(
'key'=>'xxx',
'q'=>'devnet',
'start'=>0,
'maxResults'=>10,
'filter'=>false,
'restrict'=>'',
'safeSearch'=>false,
'lr'=>'',
'ie'=>'utf-8',
'oe'=>'utf-8'
);
$queryResult = $soapclient->call('doGoogleSearch', $params);
var_dump($queryResult);
?>
i get the output:
Notice: Undefined index: in C:\netserver\www\labs\gQuery\includes\nusoap.php on line 5901
string(0) ""
error_reporting (E_ALL) by the way, so does this mean it isnt my code? maybe i have a <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> up nusoap file?? ive just downloaded what is supposedly the latest version and it is still doing it?
Posted: Mon Oct 09, 2006 12:17 pm
by volka
Did you only try this mix of both -your and my- scripts (call != __soapCall)?
please try
Code: Select all
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$params = array(
'key'=>'...',
'q'=>'devnet',
'start'=>0,
'maxResults'=>10,
'filter'=>false,
'restrict'=>'',
'safeSearch'=>false,
'lr'=>'',
'ie'=>'utf-8',
'oe'=>'utf-8'
);
$queryResult = $soapclient->__soapCall('doGoogleSearch', $params);
var_dump($queryResult);
?>
as it is, only changing 'key'=>'...'
I tested it with
PHP 5.1.6 (cli) (built: Aug 23 2006 16:35:53)
on winxp and
PHP 5.1.6-pl6-gentoo (cli) (built: Oct 9 2006 19:32:09)
without errors or warnings.
Did you give
Code: Select all
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$apiKey = '...';
$searchphrase = 'devnet';
$queryResult = $soapclient->doGoogleSearch($apiKey, $searchphrase, 0, 10, False, '', False, '', 'utf-8', "utf-8");
var_dump($queryResult);?>
a chance?
Posted: Tue Oct 10, 2006 4:48 am
by malcolmboston
volka wrote:Did you only try this mix of both -your and my- scripts (call != __soapCall)?
PHP tells me thats not a correct method
Posted: Tue Oct 10, 2006 4:50 am
by volka
Which version of php do you use?
volka wrote:Did you give
Code: Select all
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$apiKey = '...';
$searchphrase = 'devnet';
$queryResult = $soapclient->doGoogleSearch($apiKey, $searchphrase, 0, 10, False, '', False, '', 'utf-8', "utf-8");
var_dump($queryResult);?>
a chance?
Posted: Tue Oct 10, 2006 5:11 am
by malcolmboston
Code: Select all
<?php
error_reporting (E_ALL);
require ('includes/gQuery2.class.php');
require ('includes/nusoap.php');
?>
<?php
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl');
$apiKey = 'xxx';
$searchphrase = 'devnet';
// the next call is not a valid method
//$queryResult = $soapclient->doGoogleSearch($apiKey, $searchphrase, 0, 10, False, '', False, '', 'utf-8', "utf-8");
// so i do this, which ive always done, and worked fine before
$queryResult = $soapclient->call($apiKey, $searchphrase, 0, 10, False, '', False, '', 'utf-8', "utf-8");
var_dump($queryResult);?>
error:
Code: Select all
Notice: Undefined index: in C:\netserver\www\labs\gQuery\includes\nusoap.php on line 5901
string(0) ""
environment:
Code: Select all
PHP: 4.4.0 <!-- i cannot upgrade as my online host is not running PHP5 yet
OS: Windows XP