Skip to content

Instantly share code, notes, and snippets.

@undertext
Last active May 8, 2019 09:24
Show Gist options
  • Save undertext/d63f2c34477ab84703be48996c7bc191 to your computer and use it in GitHub Desktop.
Save undertext/d63f2c34477ab84703be48996c7bc191 to your computer and use it in GitHub Desktop.
UrbanDictionaryService class
public function getDefinition($term) {
try {
$response = $this->httpClient->request('GET', "http://urbanscraper.herokuapp.com/define/$term");
} catch (GuzzleException $e) {
$this->logger->error($e->getMessage());
return NULL;
}
$json = json_decode($response->getBody());
return new UrbanDefinition($json->term, $json->definition, $json->example);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment