Skip to content

Commit

Permalink
* this fixes issues with authentication process , after remarks 10REM#31
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveWilcock authored and JLTRY committed Apr 27, 2019
1 parent 27c396e commit 9f0b5f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/dawguk/GarminConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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])) {
Expand Down
8 changes: 4 additions & 4 deletions src/dawguk/GarminConnect/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit 9f0b5f2

Please sign in to comment.