public function testSetFrob() { $rtm = new Rtm(); $rtm->setFrob('v34o5dfg743535gfb'); $this->assertEquals('v34o5dfg743535gfb', $rtm->getFrob()); $rtm = new Rtm(array('frob' => 'v34o5dfg743535gfb')); $this->assertEquals('v34o5dfg743535gfb', $rtm->getFrob()); }
/** * @dataProvider getServiceMethodsMatrix */ public function testServiceMethod($serviceName, $methodName, array $parameters, array $expectedParameters, $timeline = null) { $rtm = new Rtm(); $rtm->setApiKey(self::API_KEY); $rtm->setSecret(self::SECRET); $rtm->setAuthToken(self::AUTH_TOKEN); $rtm->setFrob(self::FROB); $rtm->setClient(new ServiceTestClientMock()); $service = $rtm->getService($serviceName); if (null !== $timeline) { $service->setTimeline($timeline); } $reflection = new \ReflectionObject($service); $method = $reflection->getMethod(preg_replace('/^[\\w\\.]+\\.(\\w+)$/', '\\1', $methodName)); $response = $method->invokeArgs($service, $parameters); $this->assertEquals($serviceName, $response->__getService()); $this->assertEquals($methodName, $response->__getMethod()); $this->assertEquals($expectedParameters, $response->__getParams()); }
use Rtm\Rtm; $rtm = new Rtm(); $rtm->setApiKey(API_KEY); $rtm->setSecret(SECRET); $rtm->setAuthToken(isset($_SESSION['RTM_AUTH_TOKEN']) ? $_SESSION['RTM_AUTH_TOKEN'] : null); try { // Check authentication token $rtm->getService(Rtm::SERVICE_AUTH)->checkToken(); // Successfully authenticated, redirect to app header('Location: index.php'); } catch (Exception $e) { // Authentication request is taking place? if (isset($_GET['frob'])) { try { // Set the frob parameter $rtm->setFrob($_GET['frob']); // Call the getToken method, to acquire the token $response = $rtm->getService(Rtm::SERVICE_AUTH)->getToken(); // Save token in Rtm object $rtm->setAuthToken($response->getToken()); // Save token in session $_SESSION['RTM_AUTH_TOKEN'] = $rtm->getAuthToken(); // Check authentication token $rtm->getService(Rtm::SERVICE_AUTH)->checkToken(); // Authentication successful, redirect back to auth script to check again the token header('Location: rtm.php'); } catch (Exception $e) { echo 'Authentication failed...'; } } else { // No permissions, acquire it