3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

プリザンターから自前アプリの画面を開く

Last updated at Posted at 2020-11-16

概要

プリザンターから情報を引き継いで、自前アプリの画面を開く方法を調査。
例えば、プリザンターでログインした後に、特定のデータだけは自前アプリを作って表示するといった使い方を想定。

前提条件

  • 環境
    • OS: Windows10
    • ローカル環境に構築したプリザンター
  • 以下の詳細説明は省略
    • プリザンター
    • php

結論

プリザンターから自前アプリの画面を開けることを確認できた。
スクリプトでPOSTして自前アプリに画面遷移させる方式。
プリザンターの情報の引継ぎも可能。

詳細

自前アプリを準備

phpで簡単なページを作って、簡易サーバを起動しておく。
POSTで受け取った以下3つの情報を表示するだけの画面。

  • userId
  • userName
  • loginId

↓簡単なページ

index.php
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>
</head>
<body>
    <h1>Test Page</h1>
    <p>
        userId: <?= $_POST['userId'] ?><br/>
        userName: <?= $_POST['userName'] ?><br/>
        loginId: <?= $_POST['loginId'] ?><br/>
    </p>
</body>
</html>

↓簡易サーバ起動

>php -S localhost:8030

プリザンターにスクリプトを設定

プリザンターにフォルダを作成し、スクリプトを追加。
フォルダを開いたときに、自前アプリにPOSTするスクリプト。
プリザンターで用意されている3つの情報をPOST。

↓フォルダを作成

image.png

↓スクリプトを追加
image.png

↓スクリプトのソース

post.js
let url = 'http://localhost:8030/index.php';
// POST用のフォームを生成
let html = '<form method="post" action="' + url + '" id="form_post" style="display: none;">';
html += '<input type="hidden" name="userId" value="' + $p.userId() + '" >';
html += '<input type="hidden" name="userName" value="' + $p.userName() + '" >';
html += '<input type="hidden" name="loginId" value="' + $p.loginId() + '" >';
html += '</form>';
// bodyに追加
$("body").append(html);
// POSTで送信
$("#form_post").submit();

動作確認

ログアウトして、再度ログイン。
「他のページに遷移」のフォルダを開くと、自前アプリの画面が表示されることを確認。

image.png

↓フォルダを開くと。。。

image.png

ログインユーザの情報を自前アプリで表示できることを確認できた!

補足

上記のスクリプトを設定すると、フォルダ自体の設定ができなくなるので注意。
設定したいときはURLを直指定で設定画面を開くこと。
URLの例: http://192.168.10.10/pleasanter/items/12423/edit

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?