public function testRequestUnauthorized() { LeanClient::initialize(getenv("LC_APP_ID"), "invalid key", "invalid master key"); $this->setExpectedException("LeanCloud\\CloudException", "Unauthorized"); $data = LeanClient::request("POST", "/classes/TestObject", array("name" => "alice", "story" => "in wonderland")); LeanClient::delete("/classes/TestObject/{$data['objectId']}"); }
public static function setUpBeforeClass() { LeanClient::initialize(getenv("LC_APP_ID"), getenv("LC_APP_KEY"), getenv("LC_APP_MASTER_KEY")); LeanClient::useRegion(getenv("LC_API_REGION")); LeanClient::setStorage(new SessionStorage()); // Try to make a default user so we can login $user = new LeanUser(); $user->setUsername("alice"); $user->setPassword("blabla"); try { $user->signUp(); } catch (CloudException $ex) { // skip } }
public static function setUpBeforeClass() { LeanClient::initialize(getenv("LC_APP_ID"), getenv("LC_APP_KEY"), getenv("LC_APP_MASTER_KEY")); LeanClient::useRegion(getenv("LC_API_REGION")); }
<?php require_once "src/autoload.php"; use LeanCloud\LeanClient; use LeanCloud\Engine\LeanEngine; use LeanCloud\Engine\Cloud; LeanClient::initialize(getenv("LC_APP_ID"), getenv("LC_APP_KEY"), getenv("LC_APP_MASTER_KEY")); // define a function Cloud::define("hello", function () { return "hello"; }); // define function with named params Cloud::define("sayHello", function ($params, $user) { return "hello {$params['name']}"; }); Cloud::define("getMeta", function ($params, $user, $meta) { return array("remoteAddress" => $meta["remoteAddress"]); }); Cloud::define("updateObject", function ($params, $user) { $obj = $params["object"]; $obj->set("__testKey", 42); return $obj; }); Cloud::onLogin(function ($user) { return; }); Cloud::onInsight(function ($job) { return; }); Cloud::onVerified("sms", function ($user) { return;
/** * Initialize LeanCloud application id and key * * @return void */ public function register() { LeanClient::initialize(config('services.leancloud.id'), config('services.leancloud.key'), config('services.leancloud.masterKey')); }