protected function execute($ch)
{
$ret = curl_exec($ch);
$info = curl_getinfo($ch);
$httpCode = (int) $info["http_code"];
if ($httpCode > 299) {
switch ($httpCode) {
case 401:
throw new UnauthorizedException("Access token is invalid", 401);
break;
case 403:
throw new UnauthorizedException($ret, 403);
break;
case 404:
throw new UnauthorizedException("You need permission", 404);
break;
default:
throw new BadRequestException($ret, $info["http_code"]);
}
}
curl_close($ch);
return $ret;
}