Ben php bir googles almak arama url yaparken sorun yaşıyorum. İşte var kod:
<?php
$handle = fopen("http://www.google.com/complete/search?hl=en&js=true&qu=" .
$_GET["qu"], "r");
while (!feof($handle)) {
$text = fgets($handle);
echo $text;
}
fclose($handle);
?>
İşte alıyorum hata var:
PHP Warning: fopen(http://www.google.com/complete/search?hl=en&js=true&qu=cat): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Inetpub\test\google.php on line 3 PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\Inetpub\test\google.php on line 3
Fiddler kullanarak ve kendisi çalışıyor url üzerinde bir istek yapıyor, ama nedense php değil değilim. Herkes neden herhangi bir fikrin var mı?
güncelleme: İşte benim javascript:
function getSuggest(keyEvent) {
keyEvent = (keyEvent) ? keyEvent : window.event;
input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;
if (keyEvent.type == "keyup") {
if (input.value) {
getSearchData("google.php?qu=" + input.value);
} else {
var target = document.getElementById("targetDiv");
target.innerHTML = "<div></div>";
}
}
}
function getSearchData(dataSource) {
if (XMLHttpRequestObject) {
XMLHttpRequestObject.open("GET", dataSource);
XMLHttpRequestObject.onreadystatechange = function() {
if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
eval(XMLHttpRequestObject.responseText);
}
}
XMLHttpRequestObject.send(null);
}
}
function sendRPCDone(unusedVariable, searchTerm, arrayTerm, arrayResults, ususedArray) {
var data = "<table>";
var loopIndex;
if (arrayResults.length != 0) {
for (var loopIndex = 0; loopIndex < arrayResults.length; loopIndex++) {
data += "<tr><td>" + "<a href='http://www.google.com/search?q=" +
arrayTerm[loopIndex] + "'>" + arrayTerm[loopIndex] + '</a></td><td>' +
arrayResults[loopIndex] + "</td></tr>";
}
}
data += "</table>";
var targetDiv = document.getElementById("targetDiv");
targetDiv.innerHTML = data;
}
Ve burada benim html:
<div id="googleSearch">
Search For <input id="textField" type="text" name="textField" onkeyup="getSuggest(event)" />
<div id="targetDiv4"></div>
</div>