NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
HTTP Error: Couldn't open socket connection to server


Joined: 12 Oct 2006
Posts: 6
Location: india
Reply with quote
hi all,

I am getting the following error while i tried to implement the google api ..

Constructor error
HTTP Error: Couldn't open socket connection to server http://www.api.google.com/GoogleSearch.wsdl prior to connect(). This is often a problem looking up the host name.

Error
HTTP Error: Couldn't open socket connection to server http://www.api.google.com/GoogleSearch.wsdl prior to connect(). This is often a problem looking up the host name
.

I am not using any firewall or proxy .Tell what are the changes i have to make ..

Thanks in advance.Please reply asap its very urgent.

URS
Ram Prasath.
View user's profileFind all posts by ramprasath1983Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7901
Reply with quote
Error message is right Smile
HOST name in the URL is wrong.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Oct 2006
Posts: 6
Location: india
Reply with quote
hi dmitri,

i have tried for ,
http://www.api.google.com/GoogleSearch.wsdl and http://api.google.com/GoogleSearch.wsdl

i am getting the same error, Please let me know what is the correct url to access the google api..

Thank u

Ram Prasath.R
View user's profileFind all posts by ramprasath1983Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7901
Reply with quote
http://api.google.com/GoogleSearch.wsdl is correct, first one is not.

if correct url still does not work, check your local firewall settings for the application (php.exe if you run from PhpED).

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Oct 2006
Posts: 6
Location: india
Reply with quote
hello dmitri,

sorry to bother you,

i am not using any firewalls and i have disable the norton antivirus itself but still i am getting the same error...shall i send my code to you to review , just give me your mail id ...please help me .


Thank you,

Ram Prasath.R
View user's profileFind all posts by ramprasath1983Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7901
Reply with quote
Google API works perfectly for 1000s customers using nusoap, it's a known fact.
Regarding your problem, it's a pure networking problem.
You just have to adjust your firewall setting. Please consult with Symantec if you use their product and it stops your soap application from working. You may consult with Microsoft if it's XP's fireall blocks you. But sorry, there is nothing I could help you with this Sad

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Oct 2006
Posts: 6
Location: india
Reply with quote
Thank you dmitri,

Please do me a favour , here by i have enclosed my code for ur reference ...please try to run from ur machine and tell me the result...please do this for me.. Thank u very much

my client code:


<html>
<head>
<title>googly.php</title>
</head>
<body>
<?

require_once('../nusoap/lib/nusoap.php');

# Set parameters
$parameters = array(
'key'=>'key here',
// 'q' => $HTTP_GET_VARS['query'],
'q' => 'asdf',
'start' => '0',
'maxResults' => '10',
'filter' => 'false',
'restrict' => '',
'safeSearch' => 'false',
'lr' => '',
'ie' => '',
'oe' => ''
);

//$soapoptions = array('namespace' => 'urn:GoogleSearch','trace' => 0);

# Create a new SOAP client, feeding it GoogleSearch.wsdl on Google's site

$soapclient = new soapclient('http://api.google.com/GoogleSearch.wsdl');

$results = $soapclient->call('doGoogleSearch',$parameters,'urn:GoogleSearch');

$err = $soapclient->getError();

if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}

//$proxy = $soapclient->getProxy();

# query Google
//$results = $proxy->doGoogleSearch($parameters);

if ($soapclient->fault) {
echo '<h2>Fault</h2><pre>';
print_r($results);
echo '</pre>';
} else {
// Check for errors
$err = $soapclient->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($results);
echo '</pre>';
}
}

# Results?

if (is_array($results['resultElements']) ) {
print "<p>Your Google query for '" . $_POST['search']. "' found " .print_r($results)
. $results['estimatedTotalResultsCount'] . " results, the top ten of which
are:</p>";
foreach ( $results['resultElements'] as $results ) {
print
"<p><a href='" . $results['URL'] . "'>" .
( $results['title'] ? $results['title'] : 'no title' ) .
"</a><br />" . $results['URL'] . "<br />" .
( $results['snippet'] ? $results['snippet'] : 'no snippet' ) .
"</p>";
}
}
# No Results
else {
print "Your Google query for '" . $_POST['search'] . "' returned no results";
}

//Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($soapclient->debug_str, ENT_QUOTES) . '</pre>';

?>
</body>
</html>

Ram Prasath
View user's profileFind all posts by ramprasath1983Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7901
Reply with quote
your code works pretty good there.

The only little glitch should be corrected is
$soapclient = new soapclient('http://api.google.com/GoogleSearch.wsdl');
=>
$soapclient = new soapclient('http://api.google.com/GoogleSearch.wsdl', 'wsdl');

but it gets Google's responce without this correction too.

still, you are getting problem with your network, not with code or library.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Oct 2006
Posts: 6
Location: india
Reply with quote
Thank you very much for your effort ..Let me check out with my network connections

Thanks again..

Ram Prasath.R
View user's profileFind all posts by ramprasath1983Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 7901
Reply with quote
FYI, if you have Norton firewall, check the list of all applications in Internet Access Control tab, locate all with PHP icon and set "Permit all" or approriate custom settings for them.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 12 Oct 2006
Posts: 6
Location: india
Reply with quote
Thank u ..
Thank u very much

Ram Prasath.R
View user's profileFind all posts by ramprasath1983Send private message
HTTP Error: Couldn't open socket connection to server
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic