0

When I try to connect my parse cloud it shows an error

the username XYZ already taken

I have tried this code:

public function setUp() {
    $this->parseUser = new parseUser;
    $this->testUser = array(
        'username' => 'XYZ',
        'password' => '*******',
        'email' => '[email protected]',
        'customField' => 'customValue'
    );
}

my parseconfig.php file look like this

class parseConfig {
    const APPID = 'kS131sdje....';
    const MASTERKEY = 'w1d...';
    const RESTKEY = 'o16r...';
    const PARSEURL = 'https://api.parse.com/1/';
}

Can you help me? Is it trying to SignUp instead of Signin?

I downloaded this code from the link below and am trying to connect it to my Parse.com cloud

https://github.com/apotropaic/parse.com-php-library

1 Answer 1

1

You should check out the Parse documentation for PHP for user operations.

Here are two examples for signup and signin:

Registration:

$user = new ParseUser();
$user->set("username", "my name");
$user->set("password", "my pass");
$user->set("email", "[email protected]");

// other fields can be set just like with ParseObject
$user->set("phone", "415-392-0202");

try {
  $user->signUp();
  // Hooray! Let them use the app now.
} catch (ParseException $ex) {
  // Show the error message somewhere and let the user try again.
  echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}

Login:

try {
  $user = ParseUser::logIn("myname", "mypass");
  // Do stuff after successful login.
} catch (ParseException $error) {
  // The login failed. Check error to see why.
}
Sign up to request clarification or add additional context in comments.

3 Comments

I did it using curl. by the way thanks Wrrdpress Developer for help.
and there is no need to log in when you have MASTER KEY
It depends on your requirements. I would personally recommend against using a master key for everyday usage. I prefer to create a role that is able to do everything with the data and assign a user to this role. Then always log in with this user programmatically. This way even if this user is compromised, your master key is not. Also, don't forget to mark the answer as accepted if it answered your questions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.