我目前在尝试使用PHP SDK创建新用户时遇到错误
错误输出
You must specify a Parse class name or register the appropriate subclass when creating a new Object. Use ParseObject::create to create a subclass object.
PHP文件
$user = new ParseUser();
$user->set("username", "test");
$user->set("email", "test@gmail.com");
$user->set("password", "Cf%09ude");
try {
$user->signUp();
$result = true;
} catch (ParseException $ex) {
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
答案 0 :(得分:0)
您无法使用ParseClient::initialize
初始化SDK。加载autoload.php
后的正确用法是:
use Parse\ParseClient;
use Parse\ParseUser;
$app_id = 'your_app_id';
$rest_key = 'your_rest_key';
$master_key = 'your_master_key';
ParseClient::initialize($app_id, $rest_key, $master_key);
$user = new ParseUser();
$user->set("username", "test");
$user->set("email", "test@gmail.com");
$user->set("password", "Cf%09ude");
try {
$user->signUp();
$result = true;
} catch (ParseException $ex) {
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
上面的代码已经过测试,并且使用了正确的API密钥 - 我能够通过注释掉ParseClient::initialize
行来重现您的错误。我已submitted a Pull Request to GitHub为此方案显示更具描述性的例外情况。
答案 1 :(得分:0)