Skip to content

Instantly share code, notes, and snippets.

@donut
Last active December 13, 2015 17:29
Show Gist options
  • Save donut/4948472 to your computer and use it in GitHub Desktop.
Save donut/4948472 to your computer and use it in GitHub Desktop.
<?php
/**
* Retrieves hipsteripsum for use as dummy text.
*
* Source: http://hipsterjesus.com/
*
* @return string
* @author Donovan Mueller
**/
function beer_me($paragraph_count, $character_limit)
{
$url = "http://hipsterjesus.com/api?paras=$paragraph_count&html=false";
try {
$json = file_get_contents($url, false, null, -1);
$json = json_decode($json);
$text = substr($json->text, 0, $character_limit);
}
catch (Exception $e) {
$text = 'Error:' . $e->getMessage();
}
return $text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment