Skip to content

Instantly share code, notes, and snippets.

@tuytoosh
Last active February 27, 2023 01:52
Show Gist options
  • Save tuytoosh/4a654153795bdcf87d1f to your computer and use it in GitHub Desktop.
Save tuytoosh/4a654153795bdcf87d1f to your computer and use it in GitHub Desktop.
get google results about a keyword
<?php
// Search $title in Google search engine
public function google($title)
{
$keyword = urlencode($title);
$url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=$keyword";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'HTTP://YOURSITE.COM');
$body = curl_exec($ch);
curl_close($ch);
$array = json_decode($body);
return $array;
}
@tuytoosh
Copy link
Author

A simple function that gets info about $title and returns it as array...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment