Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Simple/controlaccesstoken.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// Simple url:
// http://www.example.org/Simple/ccontrolaccesstoken.php?access_token=D4lIOmUX7c3jK6SyF4rhZEQtWe0bJ6jv
// http://www.example.org/Simple/controlaccesstoken.php?access_token=D4lIOmUX7c3jK6SyF4rhZEQtWe0bJ6jv

require_once("../bys-client.php");
require_once("./config.php");
Expand Down
6 changes: 3 additions & 3 deletions Simple/createprovider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
try {
if (empty($_GET['refresh_token'])) {
throw new Exception('Refresh token value is empty.');
} {
} else {
// call method changeTokens, help which change refresh token for access token
$newAccessToken = $client->changeTokens($_GET['refresh_token']);

// set new access_token to variable
$access_token = $newAccessToken['access_token'];

// set provider values
$name = "New Provider";
$ico = "12345678";
Expand Down Expand Up @@ -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 '<br /> Create At: ';
Expand Down
4 changes: 2 additions & 2 deletions Simple/createuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 10 additions & 11 deletions Simple/deleteprovider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


?>
29 changes: 21 additions & 8 deletions bys-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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 {
Expand All @@ -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);

Expand Down