public function retrieve_user_details()
{
// Get the stream to the user page via the Snipt API
$request = new HTTPRequest(SNIPT_API . SNIPT_USER . SNIPT_FORMAT, HTTP_METH_GET);
echo "Connecting to Snipt API....\n";
$request->send();
if ($request->getResponseCode() == 200) {
$this->user_details = json_decode($request->getResponseBody());
echo "Snipt entries to retrieve : {$this->user_details->count}\n";
foreach ($this->user_details->snipts as $snipt) {
// Retrieve the snipt entry
$request = new HTTPRequest(SNIPT_API . SNIPT_SNIPT . $snipt . "." . SNIPT_FORMAT . SNIPT_STYLE);
$request->send();
if ($request->getResponseCode() == 200) {
$this->snipts[$snipt] = json_decode($request->getResponseBody());
} else {
echo "[ERROR] Could not retrieve the data for snipt entry {$snipt}\n";
}
}
return true;
} else {
echo "Invalid data received, exiting....\n";
return false;
}
}