-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathremove.php
More file actions
41 lines (35 loc) · 1.3 KB
/
remove.php
File metadata and controls
41 lines (35 loc) · 1.3 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
<?php
session_start();
// API URL設定
$workspace = "https://kn46itblog.com/hackathon/TechStudyGroup";
$api = "/php_apis/removeTask.php"; // APIの指定
$url = $workspace.$api;
// JSONにするオブジェクトの構成例
$data = array(
"id" => $_SESSION["id"],
"hash" => $_SESSION["hash"],
"task_id" => $_SESSION["first_id"]
);
// JSON形式に変換
$data = json_encode($data);
// ストリームコンテキストのオプションを作成
$options = array(
// HTTPコンテキストオプションをセット
'http' => array(
'method'=> 'POST',
'header'=> 'Content-type: application/json; charset=UTF-8', //JSON形式で表示
'content' => $data
)
);
// ストリームコンテキストの生成
// ストリーム
// -> I/Oデータをプログラムで扱えるよう抽象化したもの
// -> 抽象化の過程でストリームラッパーが用いられる
$context = stream_context_create($options);
// POST送信
$contents = file_get_contents($url, false, $context);
// APIのレスポンスをArrayに変換
$contents = json_decode($contents, true);
header("Location: https://kn46itblog.com/hackathon/TechStudyGroup/page.php");
exit();
?>