<form action="index.php" method="post">
search <input type="text" name="veri" id="veri">
<br>
<input type="submit" value="Gonder">
</form>
<?php
if ($_POST['veri'])
{
$veri = $_POST['veri'];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://google-search3.p.rapidapi.com/api/v1/search/q=".$veri."&num=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-rapidapi-host: google-search3.p.rapidapi.com",
"x-rapidapi-key: xxxxx",
"x-user-agent: desktop"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo "<pre>";
print_r($response);
echo "</pre>";
}
}
?>Veri Su sekilde Donuyor
{"results":[{"title":"Google","link":"https://www.google.com/","description":"Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking ...Images · Account · Google Scholar · Google Contacts","additional_links":[{"text":"Googlehttps://www.google.com","href":"https://www.google.com/"},{"text":"キャッシュ","href":"https://webcache.googleusercontent.com/search?q=cache:y14FcUQOGl4J:https://www.google.com/+&cd=1&hl=ja&ct=clnk&gl=jp"},{"text":"Images","hre f":"https://www.google.com/imghp?hl=en"},{"text":"Account","href":"https://www.google.com/account/about/"},{"text":"Google Scholar","href":"https://scholar.google.com/"},{"text":"Google Contacts","href":"https://contacts.google.com/"}],"cite":{}}],"image_results":[],"total":9410000000,"answers":[],"ts":2.6249501705169678}
Ben buradan sadece assagidaki kismi almak istiyorum yani href anahtarinin dondurdugu link lazim sadece.
"href":"https://www.google.com/"