diff --git a/.travis.yml b/.travis.yml index ebceed7..de1c678 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ php: - 7.2 env: - - LEANCLOUD_API_SERVER="https://us-api.leancloud.cn" LEANCLOUD_APP_ID=wnDg0lPt0wcYGJSiHRwHBhD4 LEANCLOUD_APP_KEY=u9ekx9HFSFFBErWwyWHFmPDy LEANCLOUD_REGION=US LEANCLOUD_APP_HOST="127.0.0.1" LEANCLOUD_APP_PORT=8081 LEANCLOUD_WILDCARD_DOMAIN="lncldglobal.com" + - LEANCLOUD_API_SERVER="https://us.avoscloud.com" LEANCLOUD_APP_ID=wnDg0lPt0wcYGJSiHRwHBhD4 LEANCLOUD_APP_KEY=u9ekx9HFSFFBErWwyWHFmPDy LEANCLOUD_REGION=US LEANCLOUD_APP_HOST="127.0.0.1" LEANCLOUD_APP_PORT=8081 LEANCLOUD_WILDCARD_DOMAIN="lncldglobal.com" install: - composer install diff --git a/Changelog.md b/Changelog.md index cf38331..6d49af4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,9 @@ + +0.10.0 发布日期:2019-06-24 +---- + +- 添加 `User::signUpOrLoginByMobilePhone` 支持手机注册或登录 + 0.9.0 发布日期:2019-05-23 ---- diff --git a/src/LeanCloud/Client.php b/src/LeanCloud/Client.php index 8b95482..faadbea 100644 --- a/src/LeanCloud/Client.php +++ b/src/LeanCloud/Client.php @@ -24,7 +24,7 @@ class Client { /** * Client version */ - const VERSION = '0.9.0'; + const VERSION = '0.10.0'; /** * API Version string diff --git a/src/LeanCloud/User.php b/src/LeanCloud/User.php index e7c56a3..d42bfe4 100644 --- a/src/LeanCloud/User.php +++ b/src/LeanCloud/User.php @@ -467,7 +467,21 @@ public static function verifyMobilePhone($smsCode) { Client::post("/verifyMobilePhone/{$smsCode}", null); } - + /** + * Sign up user by mobile phone and SMS code + * + * @param string $phoneNumber + * @param string $smsCode + */ + public static function signUpOrLoginByMobilePhone($phoneNumber, $smsCode) { + $resp = Client::post("/usersByMobilePhone", array( + "mobilePhoneNumber" => $phoneNumber, + "smsCode" => $smsCode + )); + $user = new static(); + $user->mergeAfterFetch($data); + User::saveCurrentUser($user); + } /* * Link and unlink with 3rd party auth provider diff --git a/test/UserTest.php b/test/UserTest.php index d0f2342..145e627 100644 --- a/test/UserTest.php +++ b/test/UserTest.php @@ -175,6 +175,12 @@ public function testVerifyMobilePhone() { User::verifyMobilePhone("000000"); } + public function testSignUpOrLoginByMobilePhone() { + // Ensure the post format is correct + $this->setExpectedException("LeanCloud\CloudException", null, 603); + User::signUpOrLoginByMobilePhone("18612340000", "000000"); + } + public function testLogInWithLinkedService() { $user = User::logIn("alice", "blabla");