You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Appwrite PHP SDK操作用户密码时控制台密码字段为空的问题求助

Appwrite PHP SDK操作用户密码时控制台密码字段为空的问题求助

各位大佬,我最近在使用Appwrite PHP SDK处理用户密码相关操作时遇到了一个头疼的问题,折腾好久都没解决,来求助大家!

首先是更新用户密码的场景,我写的代码如下:

<?php

require 'vendor/autoload.php';

use Appwrite\Client;
use Appwrite\Services\Users;
use Appwrite\Services\ServiceException;

$user_name = $_POST['username'];
$password = $_POST['password'];
$getUserByid = getUserByid($user_id); // 这是我自己封装的获取用户信息的方法
$appwrite_id = $getUserByid['appwrite_id'];

$client = new Client();
$client
    ->setEndpoint('Your API Endpoint')
    ->setProject('Your project ID')
    ->setKey('Your secret API key');

$users = new Users($client);

try {
    $response = $users->updatePassword($appwrite_id, $password);
    var_dump($response); // 这里能正常输出响应内容,没有报错
} catch (ServiceException $e) {
    echo 'Error updating user password: ' . $e->getMessage();
}
?>

执行这段代码后,没有抛出异常,var_dump也能返回正常的响应数据,但我去Appwrite控制台查看对应用户的信息时,密码字段始终是空的,完全没更新成功。

后来我又尝试用加密密码创建用户,代码是这样的:

$result = $users->createMD5User('[USER_ID]', 'email@example.com', 'password');

结果还是一样,用户能创建成功,但控制台里的密码字段依旧是空的。

我已经仔细看过Appwrite官方的用户相关文档,试过文档里所有和密码更新、加密密码创建用户相关的代码示例,结果都是这个情况——控制台密码字段为空。

有没有大佬能帮我看看是我代码哪里写错了,还是SDK本身有什么问题?

备注:内容来源于stack exchange,提问作者Spike Spiegel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 09:34:51