diff --git a/Simple/controlaccesstoken.php b/Simple/controlaccesstoken.php index c45bb2d..31dc0b8 100644 --- a/Simple/controlaccesstoken.php +++ b/Simple/controlaccesstoken.php @@ -1,6 +1,6 @@ changeTokens($_GET['refresh_token']); // set new access_token to variable $access_token = $newAccessToken['access_token']; - + // set provider values $name = "New Provider"; $ico = "12345678"; @@ -57,7 +57,7 @@ try { if ($newProvider['status'] != 200) { throw new Exception('Status Code is not 200.'); - } { + } else { echo 'Provider id: '; echo $newProvider['id']; echo '
Create At: '; diff --git a/Simple/createuser.php b/Simple/createuser.php index c146a5d..293ae96 100644 --- a/Simple/createuser.php +++ b/Simple/createuser.php @@ -11,7 +11,7 @@ // Set value new user. $firstName = "Ján"; $lastName = "Novák"; -$email = "m01j2j750@testbys.eu"; +$email = "m01j2j750784@testbys.eu"; $password = "123456"; $passwordAgain = "123456"; $phone = "+12345678"; @@ -52,7 +52,7 @@ // Set scope new user. - $scope = "logged_iframes+profile+manage_reservations"; + $scope = "logged_iframes+profile+manage_reservations+manage_providers+manage_profile"; // Call method "addScope" which return autentification code, which exchange for tokens. $getCode = $client->addScope($scope, $email, $password); diff --git a/Simple/deleteprovider.php b/Simple/deleteprovider.php index dd1d48a..d39de95 100644 --- a/Simple/deleteprovider.php +++ b/Simple/deleteprovider.php @@ -15,25 +15,24 @@ // First determine if session provider_id and access_token are set and aren't NULL. try { - if (empty($_GET['provider_id']) || empty($_GET['access_token'])) - { + + if (empty($_GET['provider_id']) || empty($_GET['access_token'])) { throw new Exception( 'Provider ID or Access token is null.' ); - } - { + } else { // Next call method "deleteProvider" which return info if user did deleted. $delete = $client->deleteProvider($_GET['provider_id'], $_GET['access_token']); // Control returned value. if ($delete == true) { - echo 'The user has been deleted.'; + echo 'The provider has been deleted.'; } else { - echo 'The user has not been deleted.'; - } - } + echo 'The provider has not been deleted.'; + } + } + +} catch (Exception $e) { + echo 'Error: '. $e->getMessage(); } - catch (Exception $e) { - echo 'Error: '. $e->getMessage(); - } ?> diff --git a/bys-client.php b/bys-client.php index ac5f1e9..e800bff 100644 --- a/bys-client.php +++ b/bys-client.php @@ -25,7 +25,7 @@ public function __construct() } else { try { if (file_exists(dirname(__FILE__) . "/config.php")) { - require_once(dirname(__FILE__) . "/config.php"); + require(dirname(__FILE__) . "/config.php"); } else { global $BYS_client_id; global $BYS_client_secret; @@ -145,12 +145,12 @@ public function changeTokens($refresh_token) $url = $this->setEnviromentURL() . "$part"; $grant_type = "refresh_token"; $toBody = "client_id=" . $this->client_id . "&client_secret=" . $this->client_secret . "&grant_type=" . $grant_type . "&redirect_uri=" . $this->redirect_uri . "&refresh_token=" . $refresh_token; - + $response = \Httpful\Request::post($url)->AddHeaders(array( 'client_id' => $this->client_id, 'client_secret' => $this->client_secret ))->contentType("application/x-www-form-urlencoded")->body($toBody)->send(); - + if ($response->code == 200) { $AccessTokenAndTime = array( 'status' => $response->code, @@ -229,7 +229,7 @@ public function createProvider($newProvider, $access_token) $part = "providers.json"; $url = $this->setEnviromentURL() . "$part"; - + $jsonData = array( 'name' => $newProvider->name, 'ico' => $newProvider->ico, @@ -250,7 +250,11 @@ public function createProvider($newProvider, $access_token) 'createReservationNotification' => $newProvider->createReservationNotification, 'updateReservationNotification' => $newProvider->updateReservationNotification, 'deleteReservationNotification' => $newProvider->deleteReservationNotification, - 'scope' => $newProvider->scope + 'scope' => $newProvider->scope, + 'Cache-Control' => 'no-cache', + 'client_id' => $this->client_id, + 'client_secret' => $this->client_secret, + 'access_token' => $access_token ); $json = json_encode($jsonData); @@ -310,13 +314,20 @@ public function deleteProvider($id_provider, $access_token) { $part = "providers/$id_provider.json"; $url = $this->setEnviromentURL() . "$part"; + + $jsonData = array( + 'client_id' => $this->client_id, + 'client_secret' => $this->client_secret, + 'access_token' => $access_token + ); + $json = json_encode($jsonData); $response = \Httpful\Request::delete($url)->AddHeaders(array( 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'access_token' => $access_token - ))->send(); - + ))->contentType("application/json")->body("$json")->send(); + if ($response->code == 200) { $return = true; } else { @@ -341,7 +352,9 @@ public function createUser($newUser) 'password' => $newUser->password, 'passwordAgain' => $newUser->passwordAgain, 'phone' => $newUser->phone, - 'activated' => $newUser->activated + 'activated' => $newUser->activated, + 'client_id' => $this->client_id, + 'client_secret' => $this->client_secret ); $json = json_encode($jsonData);