/Search/DuckDuckGo.php
https://github.com/bobdia/COLibrary · PHP · 35 lines · 24 code · 10 blank · 1 comment · 2 complexity · 484d0776ba1d940711d2dd6f309c63e5 MD5 · raw file
- <?php
- // http://duckduckgo.com/api.html
- class DuckDuckGo extends HttpReq {
- public $data;
-
- public $query;
- public $disambig; // disambiguation
- public $url = 'http://api.duckduckgo.com/';
- public function __construct($query, $disambiguation=null) {
- $this->query = $query;
- if($disambiguation) {
- $this->disambig = true;
- }
- }
-
- protected function before() {
- $this->args['q'] = $this->query;
- if($this->disambig) {
- $this->args['d'] = '1';
- }
- $this->args['o'] = 'json';
- }
-
- public function success() {
- $this->data = json_decode($this->body, true);
- }
-
- }
- ?>