-
+
+
・
+ +アクセストークン発行完了
+ +-
+
+
・
+ +発行完了!以下のアクセストークンでこのアカウント()に投稿を行えます!
+アクセストークンは以下のものです!
+
-
+
以下のアクセストークンは絶対に他人に知られないように大切に保管してください!
++
diff --git a/api/bot-api.php b/api/bot-api.php new file mode 100644 index 0000000..0836002 --- /dev/null +++ b/api/bot-api.php @@ -0,0 +1,127 @@ + PDO::ERRMODE_EXCEPTION, + PDO::MYSQL_ATTR_MULTI_STATEMENTS => false + ); + $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); + + } catch(PDOException $e) { + + // 接続エラーのときエラー内容を取得する + $error_message[] = $e->getMessage(); + } + + + if( !empty($pdo) ) { + + // データベース接続の設定 + $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, + )); + + $userQuery = $dbh->prepare("SELECT username, userid FROM account WHERE token = :token"); + $userQuery->bindValue(':token', $token); + $userQuery->execute(); + $userData = $userQuery->fetch(); + + if(empty($userData["userid"])){ + $err = "token_invalid"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + }else{ + // 書き込み日時を取得 + $username = $userData["username"]; + $userid = $userData["userid"]; + $datetime = date("Y-m-d H:i:s"); + $uniqid = createUniqId(); + $abi = "none"; + + // トランザクション開始 + $pdo->beginTransaction(); + + try { + + // SQL作成 + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ueuse, datetime, abi) VALUES (:username, :account, :uniqid, :ueuse, :datetime, :abi)"); + + $stmt->bindParam(':username', $username, PDO::PARAM_STR); + $stmt->bindParam(':account', $userid, PDO::PARAM_STR); + $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); + + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + + $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + + } catch(Exception $e) { + + // エラーが発生した時はロールバック + $pdo->rollBack(); + } + + if( $res ) { + $response = array( + 'uniqid' => $uniqid, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } else { + $err = "db_error_".$e->getMessage(); + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + + // プリペアドステートメントを削除 + $stmt = null; + } + } + +}else{ + + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/ltl-api.php b/api/ltl-api.php new file mode 100644 index 0000000..4a1cb97 --- /dev/null +++ b/api/ltl-api.php @@ -0,0 +1,108 @@ + PDO::ERRMODE_EXCEPTION, + PDO::MYSQL_ATTR_MULTI_STATEMENTS => false + ); + $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); + + } catch(PDOException $e) { + + // 接続エラーのときエラー内容を取得する + $error_message[] = $e->getMessage(); + } + + + if (!empty($pdo)) { + $sql = "SELECT account, username, uniqid, rpuniqid, ueuse, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE rpuniqid = '' ORDER BY datetime DESC LIMIT " . intval($offset) . ", " . intval($itemsPerPage); + $message_array = $pdo->query($sql); + + while ($row = $message_array->fetch(PDO::FETCH_ASSOC)) { + + $messages[] = $row; + } + + // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える + foreach ($messages as &$message) { + $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid"); + $userQuery->bindValue(':userid', $message["account"]); + $userQuery->execute(); + $userData = $userQuery->fetch(); + + if ($userData) { + $message['username'] = $userData['username']; + $message['role'] = $userData['role']; + } + } + + if (!empty($messages)) { + $response = array(); // ループ外で $response を初期化 + + foreach ($messages as $ueusedata) { + $favcnts = explode(',', $ueusedata["favorite"]); + $ueusedata["favorite_cnt"] = count($favcnts) - 1; + + $item = [ + 'account' => htmlentities($ueusedata["account"]), + 'username' => htmlentities($ueusedata["username"]), + 'uniqid' => htmlentities($ueusedata["uniqid"]), + 'ueuse' => htmlentities($ueusedata["ueuse"]), + 'photo1' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"])), + 'photo2' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"])), + 'video1' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"])), + 'favorite' => htmlentities($ueusedata["favorite"]), + 'favorite_cnt' => htmlentities($ueusedata["favorite_cnt"]), + 'datetime' => htmlentities($ueusedata["datetime"]), + 'abi' => htmlentities($ueusedata["abi"]), + 'abidatetime' => htmlentities($ueusedata["abidate"]), + ]; + + $response[$ueusedata["uniqid"]] = $item; // ループ内で $response にデータを追加 + } + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } else { + $err = "ueuse_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + + + $pdo = null; + } + +}else{ + + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/ueuse-api.php b/api/ueuse-api.php new file mode 100644 index 0000000..afc9a6b --- /dev/null +++ b/api/ueuse-api.php @@ -0,0 +1,89 @@ + PDO::ERRMODE_EXCEPTION, + PDO::MYSQL_ATTR_MULTI_STATEMENTS => false + ); + $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); + + } catch(PDOException $e) { + + // 接続エラーのときエラー内容を取得する + $error_message[] = $e->getMessage(); + } + + + if (!empty($pdo)) { + + $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, + )); + + $ueuseQuery = $pdo->prepare("SELECT account, ueuse, uniqid, rpuniqid, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE uniqid = :ueuseid"); + $ueuseQuery->bindValue(':ueuseid', $ueuseid); + $ueuseQuery->execute(); + $ueusedata = $ueuseQuery->fetch(); + } + +if (empty($ueusedata)){ + $response = array( + 'error_code' => "ueuseid_not_found", + ); +}else{ + $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid"); + $userQuery->bindValue(':userid', $ueusedata["account"]); + $userQuery->execute(); + $userData = $userQuery->fetch(); + if ($userData) { + $ueusedata['username'] = $userData['username']; + $ueusedata['role'] = $userData['role']; + } + + + $favcnts = explode(',', $ueusedata["favorite"]); + $ueusedata["favorite_cnt"] = count($favcnts)-1; + + $response = array( + 'userid' => htmlentities($ueusedata["account"]), + 'user_name' => htmlentities($ueusedata["username"]), + 'uniqid' => htmlentities($ueusedata["uniqid"]), + 'ueuse' => htmlentities($ueusedata["ueuse"]), + 'photo1' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo1"])), + 'photo2' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo2"])), + 'video1' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["video1"])), + 'favorite' => htmlentities($ueusedata["favorite"]), + 'favorite_cnt' => htmlentities($ueusedata["favorite_cnt"]), + 'datetime' => htmlentities($ueusedata["datetime"]), + 'abi' => htmlentities($ueusedata["abi"]), + 'abidatetime' => htmlentities($ueusedata["abidate"]), + ); +} +echo json_encode($response, JSON_UNESCAPED_UNICODE);; + +}else{ + + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/userdata-api.php b/api/userdata-api.php index 6f028c7..d7253f4 100644 --- a/api/userdata-api.php +++ b/api/userdata-api.php @@ -1,4 +1,5 @@ + +
・
+ +・
+ +発行完了!以下のアクセストークンでこのアカウント()に投稿を行えます!
+アクセストークンは以下のものです!
+
以下のアクセストークンは絶対に他人に知られないように大切に保管してください!
++