google API

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

nuSoaps expects soap:Body elements (standard conform). But http://api.google.com/GoogleSearch.wsdl contains soap:body.
quick&dirty fix:
In nuSoap.php find function start_element($parser, $name, $attrs).

Code: Select all

// get element prefix
		if(strpos($name,':')){
			// get ns prefix
			$prefix = substr($name,0,strpos($name,':'));
			// get unqualified name
			$name = ucfirst(substr(strstr($name,':'),1)); // ucfirst, quick&dirty hack
		}
		// set status

now

Code: Select all

require 'nuSoap.php';
$soapclient = new SoapClient('http://api.google.com/GoogleSearch.wsdl', true);

$params = array(
                'key'=>'...',
                'q'=>'devnet',
                'start'=>0,
                'maxResults'=>10,
                'filter'=>false,
                'restrict'=>'',
                'safeSearch'=>false,
                'lr'=>'',
                'ie'=>'utf-8',
                'oe'=>'utf-8'
        );

$queryResult = $soapclient->call('doGoogleSearch', $params);

echo '<pre>'; print_r($queryResult); echo '</pre>';
is working as expected.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

hey, havent really had time to test it but its outputting an array now anyway, that array doesnt look like the one i used to get so i dont know :? anyway dont really have time right now too look into it so ill give ya's a shout if i need anymore help :?

Thanks for the help btw volka, very much appreciated
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

hm, btw: http://www.w3.org/TR/wsdl#_soap:body[quote]3.5 soap:body[/quote]
seems like soap:Body isn't standard conform after all :roll:
Post Reply