我要求用户从链接到Joomla站点的移动应用程序重置其密码。我已经成功登录(验证并返回一个sessionid),但似乎没有重置这个外部脚本的密码。
此代码使用Joomla中所需的表单令牌会话ID成功触发POST:
<?php
define('_JEXEC', 1);
define( 'DS', DIRECTORY_SEPARATOR );
//define('JPATH_BASE', dirname(__FILE__));
define('JPATH_BASE', '../');
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
require '../libraries/import.php';
?>
<div>
<form
id="user-registration"
action="http://siteurl/component/users/com_users/?task=reset.request"
method="post">
<input
type="text"
name="jform[email]"
value="address@mydomain.co.uk"
size="30">
<button
type="submit"
>Submit</button>
<input
type="hidden"
name="<?php echo JUtility::getToken(); ?>"
value="1">
</form>
</div>
我在尝试通过cURL处理此问题时得到(bool)false的响应但是......
<?php
$token = JUtility::getToken();
$emailadr = 'email@address.co.uk';
$url = 'http://[i]siteurl[/i]/component/users/com_users/?task=reset.request';
$vars = 'jform[email]='.urlencode($emailadr).'&'.urlencode($token).'="1"';
echo $vars;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0 );
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
$response = curl_exec($ch);
var_dump($response);
这(以及大约20种其他curl参数组合,urlencode切换,数组/字符串交换)返回(bool)False。
这有什么明显的错误吗?
Joomla控件是否需要某些httpheader?