From 55d24be6e0da5f9da17ada8d1133f8d41facba2d Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 19 Apr 2014 20:23:12 -0700 Subject: [PATCH] Don't roll your own basic auth, use the Curl built in. --- gauthify.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gauthify.php b/gauthify.php index 9f1a227..1784a88 100644 --- a/gauthify.php +++ b/gauthify.php @@ -66,14 +66,11 @@ class GAuthify public function __construct($api_key) { $this->api_key = $api_key; - $this->headers = array("Authorization: " . 'Basic ' . base64_encode(':' . $api_key), - 'User-Agent: GAuthify-PHP/v2.0' - ); + $this->headers = array('User-Agent: GAuthify-PHP/v2.0'); $this->access_points = array( 'https://alpha.gauthify.com/v1/', 'https://beta.gauthify.com/v1/' ); - } @@ -87,6 +84,8 @@ private function request_handler($type, $url_addon = '', $params = array()) $req_url = $base_url . $url_addon; $type = strtoupper($type); $req = curl_init(); + curl_setopt($req, CURLOPT_USERPWD, ":" . $this->api_key); + curl_setopt($req, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($req, CURLOPT_URL, $req_url); curl_setopt($req, CURLOPT_CUSTOMREQUEST, $type); curl_setopt($req, CURLOPT_POSTFIELDS, http_build_query($params)); @@ -393,4 +392,4 @@ function success() success(); } -} +} \ No newline at end of file