Issues (209)

samples/wsdlclient6.php (1 issue)

1
<?php
2
/*
3
 *	$Id: wsdlclient6.php,v 1.1 2004/01/26 07:15:20 snichol Exp $
4
 *
5
 *	WSDL client sample.
6
 *
7
 *	Service: WSDL
8
 *	Payload: rpc/encoded
9
 *	Transport: http
10
 *	Authentication: none
11
 */
12
require_once('../lib/nusoap.php');
13
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
14
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
15
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
16
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
17
echo 'You must change the source code to specify the location of the WSDL!'; exit();
18
$client = new soapclient('file://f:/googleapi/GoogleSearch.wsdl', true,
19
						$proxyhost, $proxyport, $proxyusername, $proxypassword);
20
$err = $client->getError();
21
if ($err) {
22
	echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
23
}
24
$client->soap_defencoding = 'UTF-8';
25
26
echo 'You must set your own Google key in the source code to run this client!'; exit();
27
$key = 'set your own Google key';
28
$q = '"Lies and the Lying"';
29
$start = 1;
30
$maxResults = 10;
31
$filter = false;
32
$restrict = '';
33
$safeSearch = false;
34
$lr = '';
35
$ie = '';
36
$oe = '';
37
38
$params = array(
39
	'key' => $key, 'q' => $q, 'start' => $start, 'maxResults' => $maxResults,
40
	'filter' => $filter, 'restrict' => $restrict, 'safeSearch' => $safeSearch, 'lr' => $lr,
41
	'ie' => $ie, 'oe' => $oe
42
	);
43
44
$result = $client->call('doGoogleSearch', $params);
45
// Check for a fault
46
if ($client->fault) {
47
	echo '<h2>Fault</h2><pre>';
48
	print_r($result);
49
	echo '</pre>';
50
} else {
51
	// Check for errors
52
	$err = $client->getError();
53
	if ($err) {
54
		// Display the error
55
		echo '<h2>Error</h2><pre>' . $err . '</pre>';
56
	} else {
57
		// Display the result
58
		echo '<h2>Result</h2><pre>';
59
		print_r($result);
60
		echo '</pre>';
61
	}
62
}
63
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
64
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
65
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
66
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
67