-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
64 lines (50 loc) · 1.62 KB
/
Copy pathindex.php
File metadata and controls
64 lines (50 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
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
<?php
require 'vendor/autoload.php';
use google\appengine\api\taskqueue\PushTask;
use google\appengine\api\taskqueue\PushQueue;
$app = new Slim\App();
$app->get('/', function ($request, $response, $args) {
$response->write("Welcome to Slim!");
return $response;
});
$app->get('/create', function ($request, $response) {
$task = new PushTask('/queue',['name' => 'queue', 'action' => 'send_reminder']);
//$task_name = $task->add('kopet');
//echo 'create task: '.$task_name ;
$queue = new PushQueue('kopet');
$e = $queue->addTasks([$task]);
$e = implode(',',$e);
return 'Task added: '.$e;
});
$app->post('/queue', function ($request, $response) {
$msg = 'kopet';
$url = 'https://hooks.slack.com/services/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';
$data = ['text' => $msg];
$headers = "Content-Type: application/json";
$context = [
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode($data),
]
];
$context = stream_context_create($context);
return file_get_contents($url, false, $context);
});
$app->get('/cron', function ($request, $response) {
$msg = 'iki kronjot @'.date('Y-m-d H:i:s');
$url = 'https://hooks.slack.com/services/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';
$data = ['text' => $msg];
$headers = "Content-Type: application/json";
$context = [
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode($data),
]
];
$context = stream_context_create($context);
$result = file_get_contents($url, false, $context);
return $result;
});
$app->run();