2014-11-05 129 views
0

當我試圖連接我的解析雲它顯示了一個錯誤無法使用PHP腳本

the username XYZ already taken

我曾嘗試這個代碼連接到Parse.com雲:

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

parseconfig.php文件看起來像這樣

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

你能幫我嗎?它是試圖SignUp而不是Signin?

我下載從下面的鏈接這段代碼,我試圖將它連接到我的Parse.com雲

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

回答

1

你應該看看Parse documentation for PHP for user operations

下面是註冊和登入兩個例子:

報名:

$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(); 
} 

登錄:

try { 
    $user = ParseUser::logIn("myname", "mypass"); 
    // Do stuff after successful login. 
} catch (ParseException $error) { 
    // The login failed. Check error to see why. 
} 
+0

確定我試圖此。 – 2014-11-05 08:21:21

+0

我用捲曲來做。順便謝謝[Wrrdpress Developer](https://stackoverflow.com/users/1364793/wordpress-developer)尋求幫助。 – 2014-11-06 05:25:34

+0

並且當您有MASTER KEY時無需登錄 – 2014-11-06 05:26:31