如果它是一個定製的(單個項目使用)的動作ID從不改變安裝,所以你可以把它在移動應用中硬編碼?
否則,你就需要一個調用來檢索動作ID,2種方式浮現在腦海:
創建標籤輸出功能,並將它輸出的動作ID爲模板,然後你可以提供返回Action ID的移動開發者的特定URL。
創建監聽Session_End中對特定URL或查詢的擴展,它可以攔截和返回相關的要求: http://ellislab.com/expressionengine/user-guide/development/extension_hooks/global/session/index.html
爲了讓行動ID爲兩種方法:
$actionID = $this->EE->functions->fetch_action_id(__CLASS__, 'login_user');
您可能要考慮使用安全表單,因此請使用相同的代碼來生成XID,並使用相同的請求(可能是JSON對象)傳回,然後移動登錄可以利用這個除了Action ID以提高安全性。
$this->EE->functions->form_declaration($formDetails)
價:http://ellislab.com/expressionengine/user-guide/development/reference/functions.html#form-declaration-data-array 另外:http://ellislab.com/expressionengine/user-guide/development/guidelines/security.html#id13
也可以考慮不具有附加登錄/註冊層困擾和剛打入現有的本地EE登錄/登記,其可以以相同的方式進行模擬。
使用現有的配準的
示例:http://www.sidd3.com/stand-alone-member-registration-form-in-expressionengine/
注:
$actionID = $this->EE->functions->fetch_action_id('Member', 'member_login');
和會員註銷:
$actionID = $this->EE->functions->fetch_action_id('Member', 'member_logout');
$actionID = $this->EE->functions->fetch_action_id('Member', 'register_member');
類似的一個可以爲登錄找到
更新:
安全並不意味着https,但表單由有效的來源而不是黑客發佈!
進一步明確
假設移動開發團隊都在登錄工作。他們需要一個帶有用戶名和密碼輸入的表單,他們還需要2個隱藏字段,1個用於XID(安全檢查),1個用於ACT。表格將提交給網站的根目錄(例如www.mydomain.com)。
您需要創建的所有插件都是爲它們生成隱藏字段(或值)。這個插件可以做到以下幾點:
$actionID = $this->EE->functions->fetch_action_id("Member", 'member_login');
$formDetails = array('action' => '',
'name' => 'mobile-login',
'id' => $this->EE->TMPL->form_id,
'class' => $this->EE->TMPL->form_class,
'hidden_fields' => array('ACT' => $actionID),
'secure' => TRUE
);
return $this->EE->functions->form_declaration($formDetails);
如果模板被稱爲「移動登錄」您的根模板組中使用:
{exp:your_plugin_name form_id="my_id" form_class="my_class"}
這則呈現以下到它在使用的模板:
<form class="my_class" id="my_id" name="mobile-login" method="post" action="http://www.my-domain.com">
<div class="hiddenFields">
<input type="hidden" name="XID" value="8b13dcd4afa21fe00065319e92a53d8e72a4f687">
<input type="hidden" name="ACT" value="15">
<input type="hidden" name="site_id" value="1">
</div>
所以移動開發者既可以使用原樣,或拔出XID和ACT他們創建窗體上的包括。
您不需要另一個附件就可以爲實際登錄捕獲新的ACTion,因爲EE可以幫您實現。
謝謝,我已經更新了我的問題,請你檢查並感謝你的回答。 – aeonsleo
已解決問題的答案已更新。 –
謝謝,我瞭解這個過程。有一個故障。我無法在模板中輸出表單。其輸出沒有任何我已經打印出$ formDetails數組它輸出數組,但$ form中的$ form = $ this-> EE-functions-> form_declaration($ formDetails)'的值爲空 – aeonsleo