exit(1);
}
+/**
+ * General Exception wrapper for HTTP basic auth errors
+ *
+ * @category Integration
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ */
+class BasicAuthException extends Exception
+{
+}
+
/**
* Class for talking to the Twitter API with HTTP Basic Auth.
*
}
/**
- * Make a HTTP request using cURL.
+ * Make an HTTP request
*
* @param string $url Where to make the request
* @param array $params post parameters
*
* @return mixed the request
+ * @throws BasicAuthException
*/
function httpRequest($url, $params = null, $auth = true)
{
'follow_redirects' => true,
'connect_timeout' => 120,
'timeout' => 120,
- 'ssl_verifypeer' => false,
+ 'ssl_verify_peer' => false,
+ 'ssl_verify_host' => false
));
if ($auth) {
$response = $request->get($url);
}
+ $code = $response->getStatus();
+
+ if ($code < 200 || $code >= 400) {
+ throw new BasicAuthException($response->getBody(), $code);
+ }
+
return $response->getBody();
}