diff --git a/src/dawguk/GarminConnect.php b/src/dawguk/GarminConnect.php index 0ad7073..b1c12c7 100755 --- a/src/dawguk/GarminConnect.php +++ b/src/dawguk/GarminConnect.php @@ -141,10 +141,10 @@ private function authorize($strUsername, $strPassword) $strResponse )); } - $doc = new \DOMDocument(); - $doc->loadHTML($strResponse); - $els = $doc->getElementsByTagName('input'); - for ($i = $els->length; --$i >= 0; ) { + $objDocument = new \DOMDocument(); + $objDocument->loadHTML($strResponse); + $arrInputElements = $objDocument->getElementsByTagName('input'); + for ($i = $arrInputElements->length; --$i >= 0; ) { $element = $els->item($i); if ($element->getAttribute('name') == '_csrf') { $csrf= $element->getAttribute('value'); @@ -159,7 +159,7 @@ private function authorize($strUsername, $strPassword) "_csrf" => $csrf ); - $strResponse = $this->objConnector->post("https://sso.garmin.com/sso/login", $arrParams, $arrData, $req, false); + $strResponse = $this->objConnector->post("https://sso.garmin.com/sso/login", $arrParams, $arrData, null, false); preg_match("/ticket=([^\"]+)\"/", $strResponse, $arrMatches); if (!isset($arrMatches[1])) { diff --git a/src/dawguk/GarminConnect/Connector.php b/src/dawguk/GarminConnect/Connector.php index 69a098c..023e318 100755 --- a/src/dawguk/GarminConnect/Connector.php +++ b/src/dawguk/GarminConnect/Connector.php @@ -103,16 +103,16 @@ public function get($strUrl, $arrParams = array(), $bolAllowRedirects = true) * @param bool $bolAllowRedirects * @return mixed */ - public function post($strUrl, $arrParams = array(), $arrData = array(), $referer = null, $bolAllowRedirects = true) + public function post($strUrl, $arrParams = array(), $arrData = array(), $strReferer = null, $bolAllowRedirects = true) { curl_setopt($this->objCurl, CURLOPT_HEADER, true); curl_setopt($this->objCurl, CURLOPT_FRESH_CONNECT, true); curl_setopt($this->objCurl, CURLOPT_FOLLOWLOCATION, (bool)$bolAllowRedirects); curl_setopt($this->objCurl, CURLOPT_CUSTOMREQUEST, "POST"); - if ($referer != null) { - curl_setopt($this->objCurl, CURLOPT_REFERER, $referer); - } + if ($strReferer != null) { + curl_setopt($this->objCurl, CURLOPT_REFERER, $strReferer); + } curl_setopt($this->objCurl, CURLOPT_VERBOSE, false); if (count($arrData)) { curl_setopt($this->objCurl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));