- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
<?php
require __DIR__ . '/google-api-php-client/src/Google/autoload.php';
define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
define('SCOPES', implode(' ', array(Google_Service_Calendar::CALENDAR)));
// ini_set('error_reporting', E_ALL & ~E_NOTICE);
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
$token = array(
'access_token' => 'ya29.VgIK8cb-zWiGwy-cwE5yV4F1MiGzp4LAPogdBCxaqOs3lC8jLxeZL_xK6vEHr_HwrMcg',
'token_type' => 'Bearer',
'expires_in' => 3600,
'created' => 1451157166,
'refresh_token' => '1/oNh5t4RUGAMiYnNmyIH8iySPr0CdQpnKiXxR57Cj3EpIgOrJDtdun6zK6XiATCKT');
$json_token = json_encode($token);
$client = new Google_Client();
$client->setScopes(SCOPES);
$client->setRedirectUri('http://localhost/obscur');
$client->setAuthConfigFile(CLIENT_SECRET_PATH);
$client->setAccessType('offline');
$client->refreshToken('1/oNh5t4RUGAMiYnNmyIH8iySPr0CdQpnKiXxR57Cj3EpIgOrJDtdun6zK6XiATCKT');
$client->setAccessToken($json_token);
$flname = $_POST['flname'];
$comment = $_POST['comment'];
$startTime = str_replace(' ','T',$_POST['start']);
$endTime = str_replace(' ','T',$_POST['end']);
$members = $_POST['members'];
$phone = $_POST['phone'];
$summary = $flname + ' ' + $members + ' ' + $comment + ' ' + $phone;
if($flname && $comment && $startTime && $endTime && $members && $phone != ""){
$service = new Google_Service_Calendar($client);
$event_info = new Google_Service_Calendar_Event(array(
'summary' => 'Занято',
'description' => $summary,
'start' => array(
'dateTime' => $startTime,
'timeZone' => 'Asia/Almaty',
),
'end' => array(
'dateTime' => $endTime,
'timeZone' => 'Asia/Almaty',
),
));
$events = $service->events->listEvents('primary');
while(true) {
foreach ($events->getItems() as $event) {
if(substr($event->start->dateTime, 0, -6) == $startTime){
echo 'Извините, на данное время уже есть запись';
$exist = true;
break;
}else{
$exist = false;
}
}
$pageToken = $events->getNextPageToken();
if ($pageToken) {
$optParams = array('pageToken' => $pageToken);
$events = $service->events->listEvents('primary', $optParams);
} else {
break;
}
}
if($exist == false){
$calendarId = '[email protected]';
$event = $service->events->insert($calendarId, $event_info);
printf('Запись добавлена');
header("Location: http://localhost/obscur/забронировать.php");
}
}else{
echo "Вы заполнили не все поля";
}
?>
gost 19.01.2016 18:46 # 0
bormand 19.01.2016 18:52 # 0
HiNeX 19.01.2016 18:57 # +2
HiNeX 19.01.2016 18:57 # 0
bormand 19.01.2016 19:01 # +2
gost 19.01.2016 20:01 # 0
bormand 19.01.2016 21:05 # +2
wvxvw 19.01.2016 19:16 # +4
bormand 19.01.2016 21:06 # +1
bormand 19.01.2016 21:20 # 0
HiNeX 19.01.2016 21:24 # 0
Arris 20.01.2016 14:40 # 0
kegdan 11.02.2016 09:56 # 0
Vindicar 19.01.2016 21:27 # +1
И ведь не поправят!
acula98 24.08.2021 23:24 # 0