Last active
September 20, 2019 16:07
-
-
Save diguinhorocks/4237748 to your computer and use it in GitHub Desktop.
Revisions
-
diguinhorocks revised this gist
Sep 20, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,7 +40,7 @@ protected function queryURL() { return <<<URL https://www.googleapis.com/customsearch/v1?key={google_api_key}&cx={your_cx}&alt=atom URL; } -
diguinhorocks revised this gist
Dec 8, 2012 . 2 changed files with 3 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,10 +8,7 @@ class Request protected $response; protected $curl; public function __construct(){ } public function setQuery($query) { @@ -21,17 +18,15 @@ public function setQuery($query) public function go() { $this->curl = curl_init(); curl_setopt( $this->curl , CURLOPT_URL , ltrim( $this->queryURL() . '&q=' . urlencode($this->query) ) ); curl_setopt( $this->curl , CURLOPT_SSL_VERIFYPEER , false ); curl_setopt( $this->curl , CURLOPT_RETURNTRANSFER , 1 ); $this->response = curl_exec($this->curl); curl_close($this->curl); return $this->getResponse(); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,6 @@ include 'Request.php'; $c = new Request(); echo $c->setQuery($_GET['q'])->go(); -
diguinhorocks created this gist
Dec 8, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ <?php class Request { protected $url; protected $request; protected $response; protected $curl; public function __construct() { } public function setQuery($query) { $this->query = $query; return $this; } public function go() { $this->curl = curl_init(); curl_setopt( $this->curl , CURLOPT_URL , ltrim( $this->queryURL() . '&q=' . urlencode($this->query) ) ); curl_setopt( $this->curl , CURLOPT_SSL_VERIFYPEER , false ); curl_setopt( $this->curl , CURLOPT_RETURNTRANSFER , 1 ); $this->response = curl_exec($this->curl); curl_close($this->curl); return $this->getResponse(); } public function getResponse() { header('Content-Type: application/atom+xml'); echo $this->response; } protected function queryURL() { return <<<URL https://www.googleapis.com/customsearch/v1?key=AIzaSyCtYDYedySqc3VyEOsU2LyqC6l67MANF98&cx=012557125435830414214:wuek1hiu0n8&alt=atom URL; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form action="search.php" method="GET"> <label for="">Pesquisar: </label> <input type="text" name="q" /> </form> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <?php include 'Request.php'; $c = new Requestl(); echo $c->setQuery($_GET['q'])->go();