forked from php-tmdb/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RequestToken in the API and preparing modelling.
- Loading branch information
1 parent
41524a5
commit a8c2cc4
Showing
6 changed files
with
145 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
require_once('../../../vendor/autoload.php'); | ||
require_once('../../../apikey.php'); | ||
|
||
$token = new \Tmdb\ApiToken(TMDB_API_KEY); | ||
$client = new \Tmdb\Client($token); | ||
|
||
$requestToken = $client->getAuthenticationApi()->getNewToken(); | ||
|
||
var_dump($requestToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb; | ||
|
||
class RequestToken { | ||
/** | ||
* The token for obtaining a session | ||
* | ||
* @var string | ||
*/ | ||
private $token = null; | ||
|
||
/** | ||
* Expiry date UTC | ||
* | ||
* @var | ||
*/ | ||
private $expiresAt; | ||
|
||
/** | ||
* Token bag | ||
* | ||
* @param $request_token | ||
*/ | ||
public function __construct($request_token = null) | ||
{ | ||
$this->token = $request_token; | ||
} | ||
|
||
/** | ||
* @param null $token | ||
* @return $this | ||
*/ | ||
public function setToken($token) | ||
{ | ||
$this->token = $token; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return null | ||
*/ | ||
public function getToken() | ||
{ | ||
return $this->token; | ||
} | ||
|
||
/** | ||
* @param mixed $expiresAt | ||
* @return $this | ||
*/ | ||
public function setExpiresAt($expiresAt) | ||
{ | ||
if (!$expiresAt instanceof \DateTime) { | ||
$expiresAt = new \DateTime($expiresAt); | ||
} | ||
|
||
$this->expiresAt = $expiresAt; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getExpiresAt() | ||
{ | ||
return $this->expiresAt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
class RequestTokenTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
const REQUEST_TOKEN = '641bf16c663db167c6cffcdff41126039d4445bf'; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function testSetGet() | ||
{ | ||
$token = new \Tmdb\RequestToken(); | ||
$token->setToken(self::REQUEST_TOKEN); | ||
$token->setExpiresAt('2012-02-09 19:50:25 UTC'); | ||
|
||
$this->assertEquals(self::REQUEST_TOKEN, $token->getToken()); | ||
$this->assertInstanceOf('DateTime', $token->getExpiresAt()); | ||
} | ||
} |